[
https://issues.apache.org/jira/browse/CALCITE-7885?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-7885.
----------------------------------
Fix Version/s: 1.43.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/c368970b2950903432ed61ecd7ff404a67e16fb1]
Thank you for your review [~zwh]
> RelDecorrelator merges distinct correlation fields and produces extra rows
> --------------------------------------------------------------------------
>
> Key: CALCITE-7885
> URL: https://issues.apache.org/jira/browse/CALCITE-7885
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: zzwqqq
> Assignee: zzwqqq
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.43.0
>
>
> {{rewriteScalarAggregate}} uses aggregate column positions as keys in
> {{{}newProjectMap{}}}. Different outer references can share a position, so
> one overwrites another. When their values differ on unmatched rows, the final
> join can attach an aggregate result to the wrong outer row.
> For example:
> {code:sql}
> with t(x, y) as (values (1, 1), (2, 1)),
> s(z) as (values (1))
> select t.x, t.y,
> (select count(*) from s where s.z = t.x and s.z = t.y) as c
> from t;
> {code}
> Expected:
> {code:sql}
> +---+---+---+
> | X | Y | C |
> +---+---+---+
> | 1 | 1 | 1 |
> | 2 | 1 | 0 |
> +---+---+---+
> (2 rows)
> {code}
> Actual:
> {code:sql}
> +---+---+---+
> | X | Y | C |
> +---+---+---+
> | 1 | 1 | 1 |
> | 2 | 1 | 0 |
> | 1 | 1 | 0 |
> +---+---+---+
> (3 rows)
> {code}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)