Skip to content

window functions with NULL literals in partition by and order by do not work: Internal("Sort operation is not applicable to scalar value NULL") #1194

Closed

Description

@alamb

Reproducer:

echo "1" > /tmp/foo.csv
cargo run -p datafusion-cli
CREATE EXTERNAL TABLE foo(x int)
STORED AS CSV
LOCATION '/tmp/foo.csv';
> select percent_rank() OVER (partition by x) from foo;
+----------------+
| PERCENT_RANK() |
+----------------+
| 0              |
+----------------+
1 row in set. Query took 0.013 seconds.
> select percent_rank() OVER (partition by null) from foo;
ArrowError(ExternalError(ArrowError(ExternalError(Internal("Sort operation is not applicable to scalar value NULL")))))


> select percent_rank() OVER (partition by x order by null) from foo;
ArrowError(ExternalError(ArrowError(ExternalError(Internal("Sort operation is not applicable to scalar value NULL")))))

The correct output is null

See #1184 for more details

Activity

  1. changed the title [-]window functions with NULL literals in `partition by` and `order by` do not work[/-] [+]window functions with NULL literals in `partition by` and `order by` do not work: Internal("Sort operation is not applicable to scalar value NULL")[/+] on Oct 28, 2021
  2. alamb commented on Oct 28, 2021

    @alamb
    ContributorAuthor

    #1195 may be the same underlying cause

  3. xudong963 commented on Oct 28, 2021

    @xudong963
    Member

    #1195 may be the same underlying cause

    @alamb Nice! It's the same cause.

    > CREATE EXTERNAL TABLE foo(x int)
    STORED AS CSV
    LOCATION '/tmp/foo.csv';
    0 rows in set. Query took 0.002 seconds.
    > select percent_rank() OVER (partition by x) from foo;
    +----------------+
    | PERCENT_RANK() |
    +----------------+
    | 0              |
    +----------------+
    1 row in set. Query took 0.019 seconds.
    > select percent_rank() OVER (partition by null) from foo;
    +----------------+
    | PERCENT_RANK() |
    +----------------+
    | 0              |
    +----------------+
    1 row in set. Query took 0.014 seconds.
    > select percent_rank() OVER (partition by x order by null) from foo;
    +----------------+
    | PERCENT_RANK() |
    +----------------+
    | 0              |
    +----------------+
    1 row in set. Query took 0.014 seconds.
    >
    
  4. xudong963 commented on Oct 29, 2021

    @xudong963
    Member

    Maybe the issue can close too.

  5. alamb commented on Oct 29, 2021

    @alamb
    ContributorAuthor

    As @xudong963 mentions, closed in #1197

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions