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

@alamb

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

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