Skip to content

Group By All - #7622

Merged
alamb merged 5 commits into
apache:mainfrom
synnada-ai:feature/groupby-all
Sep 22, 2023
Merged

Group By All#7622
alamb merged 5 commits into
apache:mainfrom
synnada-ai:feature/groupby-all

Conversation

@berkaysynnada

@berkaysynnada berkaysynnada commented Sep 22, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

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

alamb commented Sep 22, 2023

Copy link
Copy Markdown
Contributor

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
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