[ 
https://issues.apache.org/jira/browse/CALCITE-7973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152320#comment-18152320
 ] 

zzwqqq commented on CALCITE-7973:
---------------------------------

Thanks, [~jensen] . I’ve restored the original title and added the more precise 
wording at the top of the description.

> RelBuilder can incorrectly skip DISTINCT when getMaxRowCount underestimates 
> FULL JOIN cardinality
> -------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7973
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7973
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: zzwqqq
>            Assignee: zzwqqq
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.43.0
>
>
> A title that identifies the root cause would be “*RelMdMaxRowCount can 
> underestimate the maximum row count of a FULL JOIN*”. 
> The original title is kept to match the merged commit message.
> {code:sql}
> SELECT DISTINCT 6 AS v
> FROM (VALUES (1)) AS l(k)
> FULL JOIN (VALUES (2)) AS r(k) ON l.k = r.k;
> {code}
> Actual result
> {code:sql}
> +---+
> | V |
> +---+
> | 6 |
> | 6 |
> +---+
> (2 rows)
> {code}
> Expected result
> {code:sql}
> +---+
> | V |
> +---+
> | 6 |
> +---+
> (1 row)
> {code}
> The join keys differ, so the FULL JOIN returns both unmatched rows. 
> RelMdMaxRowCount.getMaxRowCount multiplies the two input bounds (1 × 1) and 
> reports that the join can return at most one row. RelBuilder.alreadyUnique() 
> therefore returns true, and RelBuilder skips the aggregate that would 
> implement DISTINCT.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to