[
https://issues.apache.org/jira/browse/CALCITE-7675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18099568#comment-18099568
]
Julian Hyde commented on CALCITE-7675:
--------------------------------------
[~tisyabhatia], Which Calcite component are you proposing to modify, and what
problem are you trying to solve? We already have planner rules (or
{{RelBuilder}} logic, I forget which) to remove constant values from
{{Aggregate}} and {{Sort}} relational operators. But we shouldn't apply a
blanket policy that bans constants in those places, nor assume that someone
else has already removed them.
> GROUP BY ALL / ORDER BY ALL should exclude constant literals from the
> implicit keys
> -----------------------------------------------------------------------------------
>
> Key: CALCITE-7675
> URL: https://issues.apache.org/jira/browse/CALCITE-7675
> Project: Calcite
> Issue Type: Bug
> Reporter: Tisya Bhatia
> Priority: Major
>
> 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)