Skip to content

[CALCITE-7647] Support SELECT * in GROUP BY ALL and ORDER BY ALL#5089

Open
tisyabhatia wants to merge 1 commit into
apache:mainfrom
tisyabhatia:group-by-order-by-all-select-star
Open

[CALCITE-7647] Support SELECT * in GROUP BY ALL and ORDER BY ALL#5089
tisyabhatia wants to merge 1 commit into
apache:mainfrom
tisyabhatia:group-by-order-by-all-select-star

Conversation

@tisyabhatia

@tisyabhatia tisyabhatia commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Jira Link

CALCITE-7647

Changes Proposed

Expand a bare or qualified star in the SELECT clause to its underlying columns when rewriting GROUP BY ALL / ORDER BY ALL, so those clauses no longer reject SELECT *. Star items are expanded via the existing column-enumeration path (matching normal SELECT * semantics), before the placeholder is replaced with the concrete keys.

Comment thread core/src/test/resources/sql/agg.iq
Comment thread core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java Outdated
Comment thread core/src/test/resources/sql/sort.iq Outdated
@mihaibudiu

Copy link
Copy Markdown
Contributor

I think something went wrong in your rebase, you are showing some commits which you shouldn't. Do not merge main, rebase on main.

@tisyabhatia
tisyabhatia force-pushed the group-by-order-by-all-select-star branch from 0d8a6af to 9b20a08 Compare July 15, 2026 16:32

@mihaibudiu mihaibudiu 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.

I approved, but please make the messages match

Comment thread core/src/test/resources/sql/sort.iq Outdated
!ok

# [CALCITE-7647] ORDER BY ALL expands SELECT * to every underlying column
# [CALCITE-7647] ORDER BY ALL expands SELECT * to every underlying column.

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.

You should use the same message here as the commit/JIRA message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, thank you for your reviews @mihaibudiu and @xuzifu666

@xuzifu666 xuzifu666 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I approve it If you address comment raised by @mihaibudiu .

@tisyabhatia
tisyabhatia force-pushed the group-by-order-by-all-select-star branch from 9b20a08 to c6bdc63 Compare July 16, 2026 17:29
@mihaibudiu

Copy link
Copy Markdown
Contributor

Good. Now you need to squash the commits to one with this message and we can merge

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Jul 16, 2026
Expand a bare or qualified star in the SELECT clause to its underlying
columns when rewriting GROUP BY ALL / ORDER BY ALL, so those clauses no
longer reject SELECT *. Star items are expanded via the existing
column-enumeration path (matching normal SELECT * semantics, including
NATURAL JOIN coalescing), before the placeholder is replaced with the
concrete keys.

Add rewritesTo assertions that show the columns SELECT * expands to as
grouping/sort keys, and tighten the .ok()-case comments to match what
they actually verify. The expected output in the agg.iq / sort.iq cases
was validated against DuckDB.
@tisyabhatia
tisyabhatia force-pushed the group-by-order-by-all-select-star branch from c6bdc63 to c99c1a4 Compare July 17, 2026 17:11
@sonarqubecloud

Copy link
Copy Markdown


# [CALCITE-7647] Support SELECT * in GROUP BY ALL and ORDER BY ALL.
# ORDER BY ALL expands SELECT * to every underlying column.
# Expected output validated against DuckDB (https://shell.duckdb.org).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can keep this in the PR; let's not put it in the test file.

+---+---+
(3 rows)

!ok

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add a test case involving duplicate columns? For example, SELECT *, deptno FROM emp GROUP BY ALL, or perhaps some other edge cases?

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.

Please address these new comments too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants