[
https://issues.apache.org/jira/browse/CALCITE-1710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15937092#comment-15937092
]
Julian Hyde commented on CALCITE-1710:
--------------------------------------
I suspect that a developer went ahead and implemented an associativity rule for
'+' (thus can deduce that {{(1 + x) + y}} is equivalent to {{1 + (x + y)}}) but
didn't tell the PM who wrote the specification, and that page.
But the developer didn't go one step further an implement an commutivity rule
(which could have deduced that {{(ColumnA + constant) + ColumnB}} is equivalent
to {{(ColumnA + ColumnB) + constant}} and would therefore have allowed {{SELECT
ColumnA + constant + ColumnB FROM T GROUP BY ColumnA + ColumnB}}, which that
page explictly disallows).
I disagree with SQL Server's implementation. Simple is better. Structural
matching is the way to go. Which is what Oracle does, and is consistent with
SQL Server's specification.
> GroupBy columns support arithmetic expression
> ---------------------------------------------
>
> Key: CALCITE-1710
> URL: https://issues.apache.org/jira/browse/CALCITE-1710
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: lincoln.lee
> Assignee: Julian Hyde
> Priority: Minor
>
> Currently only original column reference(s) and column(s) with UDF valid in
> group by clause but arithmetic expression(s) not allowed, while most RDBMS
> support
> like thus:
> {code}
> SELECT
> ColumnA + ColumnB
> FROM T
> GROUP BY ColumnA + ColumnB;
>
> SELECT
> ColumnA + ColumnB + constant
> FROM T
> GROUP BY ColumnA, ColumnB;
> SELECT
> ColumnA % 3
> FROM T
> GROUP BY ColumnA %3;
> {code}
> we can treat these arithmetic operators as builtin UDFs and support these
> kind of query, it'll be a useful feature.
> What do you think?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)