You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Tisya Bhatia (Jira)" <ji...@apache.org> on 2026/08/14 18:26:00 UTC

[jira] [Updated] (CALCITE-7675) GROUP BY ALL and ORDER BY ALL should infer keys only from expressions that depend on the input

     [ https://issues.apache.org/jira/browse/CALCITE-7675?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tisya Bhatia updated CALCITE-7675:
----------------------------------
    Summary: GROUP BY ALL and ORDER BY ALL should infer keys only from expressions that depend on the input  (was: GROUP BY ALL and ORDER BY ALL should infer keys only from expressions that depend on the input- #5127)

> GROUP BY ALL and ORDER BY ALL should infer keys only from expressions that depend on the input
> ----------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7675
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7675
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Tisya Bhatia
>            Priority: Major
>              Labels: pull-request-available
>
> GROUP BY ALL (CALCITE-7594) and ORDER BY ALL (CALCITE-7597) expand into every non-aggregate SELECT expression during validation. The expansion currently also adds constant literals to the implicit keys.
> Example:
> SELECT count( * ), 42 AS c FROM emp GROUP BY ALL; – becomes GROUP BY 42
> SELECT sal, 42 AS c FROM emp ORDER BY ALL; – becomes ORDER BY 42
> Motivation: grouping or sorting by a constant is a no-op, and materializing it produces an ambiguous "GROUP BY 42" / "ORDER BY 42". On unparse round-trips (view / materialized-table expansion, SqlValidatorFixture#rewritesTo) it is re-parsed as an ordinal position under ordinal-style conformances and fails as out of range, and is a constant key under DEFAULT.
> Proposed behaviour:
> * rewriteGroupByAll / rewriteOrderByAll skip SELECT items that are a SqlLiteral, so a constant never becomes an implicit key. This is result-equivalent (one group / no reordering either way).
> * Only bare literals are affected; compound constant expressions such as 1 + 1 are SqlCalls, are never treated as ordinals, and are intentionally left alone.
> Follow-up to CALCITE-7594 / CALCITE-7597; GROUP BY ALL and ORDER BY ALL only.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)