[
https://issues.apache.org/jira/browse/CALCITE-4818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17425397#comment-17425397
]
Taras Ledkov commented on CALCITE-4818:
---------------------------------------
[~wojustme], thanks for review and propose the test case.
Please clarify what do you mean:
- replace SQL from {{SELECT SUM(comm), SUM(DISTINCT comm) FROM emp}} to
proposed {{SELECT s1+1 AS new_s1, s2+1 AS new_s2 FROM (SELECT SUM(comm) AS s1,
SUM(DISTINCT comm) AS s2 FROM emp)}} at the added test
- add new test.
What the key difference do you see between
{{SELECT SUM(comm), SUM(DISTINCT comm) FROM emp}}
and
{{SELECT s1+1 AS new_s1, s2+1 AS new_s2 FROM (SELECT SUM(comm) AS s1,
SUM(DISTINCT comm) AS s2 FROM emp)}}
for the issue at the {{AggregateExpandDistinctAggregatesRule}}?
> AggregateExpandDistinctAggregatesRule must infer correct data type for top
> aggregate calls
> ------------------------------------------------------------------------------------------
>
> Key: CALCITE-4818
> URL: https://issues.apache.org/jira/browse/CALCITE-4818
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.27.0
> Reporter: Taras Ledkov
> Assignee: Taras Ledkov
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.28.0
>
>
> When SUM data type derivation is more complex, e.g.:
> {code}
> SUM(TINYINT | SMALLINT | INTEGER) -> BIGINT
> SUM(BIGINT) -> DECIMAL
> {code}
> The rule {{AggregateExpandDistinctAggregatesRule}} creates the top aggregate
> calls with invalid type for not distinct calls.
> e.g. {{SELECT SUM(comm), SUM(DISTINCT comm) FROM emp}}
> Please take a look at the reproducer in the PR.
> *Proposed fix:* infer type of top aggregates by input row type. Pass
> {{null}} type to the call method {{AggregateCall#create}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)