-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reject RESPECT NULLS
and IGNORE NULLS
for aggregate functions
#15014
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5863,15 +5863,11 @@ SELECT FIRST_VALUE(column1) FROM t; | |
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT FIRST_VALUE(column1) RESPECT NULLS FROM t; | ||
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT FIRST_VALUE(column1) IGNORE NULLS FROM t; | ||
---- | ||
3 | ||
|
||
statement ok | ||
DROP TABLE t; | ||
|
@@ -5893,15 +5889,11 @@ SELECT FIRST_VALUE(column1 ORDER BY column2) FROM t; | |
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT FIRST_VALUE(column1 ORDER BY column2) RESPECT NULLS FROM t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure about this change -- the query seems valid to me as there is a null and an argument order, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit of the weirdness I pointed out in #15006, which is that DataFusion has This invocation is technically the aggregate function form, because there is no OVER clause which would be expected for a window function invocation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree -- I think spark behaves this way which is why someone added the feature to DataFusion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, there's always another engine 😅 It looks like Spark defines a Spark Docs: https://spark.apache.org/docs/latest/api/sql/index.html#first_value |
||
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT FIRST_VALUE(column1 ORDER BY column2) IGNORE NULLS FROM t; | ||
---- | ||
4 | ||
|
||
statement ok | ||
DROP TABLE t; | ||
|
@@ -5915,15 +5907,11 @@ SELECT LAST_VALUE(column1) FROM t; | |
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT LAST_VALUE(column1) RESPECT NULLS FROM t; | ||
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT LAST_VALUE(column1) IGNORE NULLS FROM t; | ||
---- | ||
4 | ||
|
||
statement ok | ||
DROP TABLE t; | ||
|
@@ -5945,15 +5933,11 @@ SELECT LAST_VALUE(column1 ORDER BY column2 DESC) FROM t; | |
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT LAST_VALUE(column1 ORDER BY column2 DESC) RESPECT NULLS FROM t; | ||
---- | ||
NULL | ||
|
||
query I | ||
query error DataFusion error: Error during planning: RESPECT NULLS and IGNORE NULLS are not supported for aggregate functions | ||
SELECT LAST_VALUE(column1 ORDER BY column2 DESC) IGNORE NULLS FROM t; | ||
---- | ||
3 | ||
|
||
statement ok | ||
DROP TABLE t; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider it to be a parser responsibility, for example duckDB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I totally agree! Does this mean I should make change in https://github.com/apache/datafusion-sqlparser-rs ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think someone needs to go see what spark does too -- as I recall this was some feature from spark that someone added explicitly...
Maybe @andygrove or @huaxingao remembers 🤔