[ 
https://issues.apache.org/jira/browse/CALCITE-7963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-7963:
------------------------------------
    Labels: pull-request-available  (was: )

> RelFieldTrimmer incorrectly includes right-side fields in the output mapping 
> for SEMI and ANTI correlates
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7963
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7963
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: zzwqqq
>            Assignee: zzwqqq
>            Priority: Major
>              Labels: pull-request-available
>
> A SEMI or ANTI LogicalCorrelate outputs only its left input's fields. When 
> RelFieldTrimmer rebuilds the correlate, it concatenates the left and right 
> input mappings and returns the result as the output mapping.
> Configure the planner to run CoreRules.JOIN_ON_UNIQUE_TO_SEMI_JOIN followed 
> by CoreRules.JOIN_TO_CORRELATE after decorrelation and before field trimming.
> {code:sql}
> SELECT l.k
> FROM (VALUES (1), (2)) AS l(k)
> WHERE EXISTS (SELECT 1 FROM (VALUES (1)) AS r(k) WHERE r.k = l.k);
> {code}
> Preparing the query throws an AssertionError.
> {code}
> java.lang.AssertionError: rowType: RecordType(INTEGER K), mapping: [size=2, 
> sourceCount=3, targetCount=2, elements=[0:0, 2:1]]
> {code}
> To reproduce the ANTI case, change EXISTS to NOT EXISTS and use 
> CoreRules.OUTER_JOIN_TO_ANTI_JOIN as the first rule.
> I've verified the sql https://onecompiler.com/postgresql/45a4ewefr



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

Reply via email to