Skip to content
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

Make aggregation statement compilation robust #2781

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LantaoJin
Copy link
Member

@LantaoJin LantaoJin commented Jun 27, 2024

Description

This PR is to address the weakness of query compilation for aggregation statement, including query with aggregate function, window function, group-by clause etc.

Here are some examples to demo what this PR fixes. The reproduce details is here

ID Query Description Before After (SemanticCheckException)
1 SELECT query_id FROM test_bulk1 GROUP BY name column not in group-by clause return null Field [query_id] must appear in the GROUP BY clause or be used in an aggregate function
2 SELECT query_id, max(query_id) FROM test_bulk1 group-by is missing Explicit GROUP BY clause is required because expression [query_id] contains non-aggregated column Explicit GROUP BY clause is required because expression [query_id] contains non-aggregated column
3 SELECT query_id FROM test_bulk1 GROUP BY max(query_id) aggregate functions in group-by Server side error during query execution Aggregate function is not allowed in a GROUP BY clause, but found [max]
4 SELECT max(query_id) FROM test_bulk1 GROUP BY 1 group-by position refers to aggregate function Server side error during query execution Aggregate function is not allowed in a GROUP BY clause, but found [max]
5 SELECT max(query_id) FILTER(WHERE query_id) FROM test_bulk1 non boolean filter in aggregate Client side error during query execution: [filter] must not be null FILTER or HAVING expression must be type boolean, but found [LONG]
6 SELECT max(query_id) FILTER(WHERE max(query_id)>10) FROM test_bulk1 aggregate in aggregate-filter error Server side error during query execution Aggregate function is not allowed in a FILTER, but found [max]
7 SELECT * FROM test_bulk1 WHERE ROW_NUMBER() OVER(ORDER BY name) > 0 window function in where-clause Server side error during query execution window functions are not allowed in WHERE or HAVING

Issues Resolved

Resolves #2767, #910,

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Lantao Jin <ltjin@amazon.com>
@LantaoJin LantaoJin force-pushed the pr/rfc_issue_2767 branch from 23da5b0 to 1c8a5ae Compare July 4, 2024 07:13
Signed-off-by: Lantao Jin <ltjin@amazon.com>
@LantaoJin
Copy link
Member Author

All checks passed on latest commit. @penghuo @dai-chen would you have a chance to review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Make aggregation statement compilation robust
1 participant