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

Group By All #7622

Merged
merged 5 commits into from
Sep 22, 2023
Merged

Group By All #7622

merged 5 commits into from
Sep 22, 2023

Conversation

berkaysynnada
Copy link
Contributor

@berkaysynnada berkaysynnada commented Sep 22, 2023

Which issue does this PR close?

Closes #.
Closes #7619

Rationale for this change

There exists a GROUP BY usage with ALL keyword in some platforms (https://docs.snowflake.com/en/sql-reference/constructs/group-by#label-group-by-all-columns, https://duckdb.org/docs/sql/query_syntax/groupby.html).

It groups together all the columns in the SELECT statement that aren't enclosed within aggregate functions. This streamlines the syntax by keeping the list of columns in one place and helps avoid errors by ensuring that the level of detail in your SELECT matches the grouping in your GROUP BY clause.

sqlparser part supports it now with the 0.38.0 release.

What changes are included in this PR?

  • sqlparser is updated from 0.37.0 to 0.38.0.

  • select_to_plan() can handle ALL option of GroupByExpr, by grouping all select expressions except aggregate functions.

  • .slt tests added.

Are these changes tested?

Yes, with groupby.slt tests extended.

Are there any user-facing changes?

Users can make use of GROUP BY ALL syntax for large grouping sets.

@github-actions github-actions bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Sep 22, 2023
@berkaysynnada berkaysynnada changed the title Group By Al Group By All Sep 22, 2023
} else {
// 'group by all' groups wrt. all select expressions except 'AggregateFunction's.
// Filter and collect non-aggregate select expressions
select_exprs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 very nice explanation and code

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thank you @berkaysynnada

@alamb
Copy link
Contributor

alamb commented Sep 22, 2023

I think this is a pretty small code change so I am just going to merge it in. Thanks again @berkaysynnada

@alamb alamb merged commit 70b8620 into apache:main Sep 22, 2023
23 checks passed
Ted-Jiang pushed a commit to Ted-Jiang/arrow-datafusion that referenced this pull request Oct 7, 2023
* group by all is resolved

* restore the removed tests

* tests extended

* fix after merge
@berkaysynnada berkaysynnada deleted the feature/groupby-all branch November 10, 2023 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants