-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25708][SQL] HAVING without GROUP BY means global aggregate #22696
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
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 |
|---|---|---|
|
|
@@ -73,3 +73,10 @@ where b.z != b.z; | |
| -- SPARK-24369 multiple distinct aggregations having the same argument set | ||
| SELECT corr(DISTINCT x, y), corr(DISTINCT y, x), count(*) | ||
| FROM (VALUES (1, 1), (2, 2), (2, 2)) t(x, y); | ||
|
|
||
| -- SPARK-25708 HAVING without GROUP BY means global aggregate | ||
| SELECT 1 FROM range(10) HAVING true; | ||
|
||
|
|
||
| SELECT 1 FROM range(10) HAVING MAX(id) > 0; | ||
|
||
|
|
||
| SELECT id FROM range(10) HAVING id > 0; | ||
|
Contributor
Author
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. before this fix, this returns 10 rows, now it fails. |
||
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.
Is this query legal? Can we run such query in a test?
I read the articles here and here. One point gets my attention. Below is Postgres documentation about
HAVINGwithoutGROUP BY:Please see the bold text. Seems to me in this query, we can't have
x < 1as condition inHAVINGbecausexis not within aggregate functions. ditto foraandbinSELECTlist.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 this query is invalid.
Note that this is parser suite. A lot of test cases in this suite are using invalid queries.