Skip to content

[FLINK-40344][table] Support selecting computed grouping expressions - #28987

Open
beetle0915 wants to merge 5 commits into
apache:masterfrom
beetle0915:FLINK-40344-computed-grouping-expression
Open

[FLINK-40344][table] Support selecting computed grouping expressions#28987
beetle0915 wants to merge 5 commits into
apache:masterfrom
beetle0915:FLINK-40344-computed-grouping-expression

Conversation

@beetle0915

Copy link
Copy Markdown

What is the purpose of the change

This change fixes the selection of computed grouping expressions in the Table API.

Previously, a computed grouping expression such as a > 10 was materialized as an aggregate output field, but a subsequent projection attempted to resolve the original expression against the aggregate output. Since the original field a was no longer available, validation failed.

Brief change log

  • Assign stable output names to computed grouping expressions.
  • Replace matching grouping expressions in aggregate projections with references to the corresponding aggregate output fields.
  • Unwrap grouping expression aliases when serializing GROUP BY.
  • Add regression tests for direct reuse and structurally equivalent computed grouping expressions.
  • Cover both groupBy(...).select(...) and explicit groupBy(...).aggregate(...).select(...) paths while ensuring that non-grouping expressions remain rejected.

Verifying this change

This change added tests in QueryOperationSqlSerializationTest covering:

  • Selecting the same computed grouping expression.
  • Selecting a structurally equivalent computed grouping expression with an alias.
  • Selecting a computed grouping expression after an explicit aggregate() call.
  • Ensuring that a non-grouping expression is still rejected.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes

Generated-by: OpenAI Codex (GPT-5)

Rewrite computed grouping expressions to reference aggregate output fields and add regression tests.

Generated-by: OpenAI Codex (GPT-5)
@flinkbot

flinkbot commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@beetle0915

Copy link
Copy Markdown
Author

@flinkbot run azure

@beetle0915

Copy link
Copy Markdown
Author

The latest Azure CI run has passed successfully on the current head (cd82e7c). This PR is ready for review. Thanks!

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.

2 participants