tisyabhatia opened a new pull request, #28381: URL: https://github.com/apache/flink/pull/28381
## What is the purpose of the change This pull request adds initial support for positional references in the GROUP BY clause (GROUP BY <n>) in Flink SQL. When enabled, an integer literal n in GROUP BY refers to the n-th expression in the SELECT list. **Because this changes the meaning of existing queries, the behavior is gated behind a new table config option that is disabled by default**. It is intended to flip to true in a future release after a customer-notice period. This feature requires no parser / grammar changes as Apache Calcite (apache/calcite) already resolves group ordinals when its SqlConformance.isGroupByOrdinal() returns true. Flink simply enables that resolution per the config flag by wrapping the validator's conformance, so Calcite's ordinal resolution and error handling are reused as-is. This work is backed by an internal design doc and a FLIP (currently under review). ## Brief change log - Add table config option table.group-by-ordinal-enabled (default false) gating the behavior - Wrap the conformance in FlinkCalciteSqlValidator so isGroupByOrdinal() returns true only when the option is enabled, reusing Calcite's native group-ordinal resolution - Add batch SQL execution tests in GroupByOrdinalTest ## Verifying this change This change added tests and can be verified as follows: - Batch SQL execution coverage in GroupByOrdinalTest (parametrized: ordinal -> column, multiple ordinals, ordinal mixed with explicit column, ordinal -> whole expression; plus the flag-off "literal stays a constant" case and out-of-range, zero-ordinal, and ordinal-points-at-an-aggregated errors) - Verified the feature is gated by the table.group-by-ordinal-enabled config option (off by default preserves existing GROUP BY <constant> semantics) ## Does this pull request potentially affect one of the following parts: - Dependencies: no - `@Public(Evolving) `API: no - Serializers: no - Runtime per-record code paths: no - Deployment/recovery (JobManager, Checkpointing, K8s/Yarn, ZK): no - S3 file system connector: no ## Documentation - Introduces a new feature? yes - How documented? Not documented in this PR Was generative AI tooling used to co-author this PR? Yes - Generated-by: Claude Code -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
