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

Mihai Budiu commented on CALCITE-7646:
--------------------------------------

In the process of creating this PR Claude has noticed that there is a bug in 
the previous implementation of the extractor: it was not marking a field which 
is *not* being moved as belonging to the Correlate.requiredColumns. This 
omission can cause the field to be incorrectly trimmed or can lead to incorrect 
plans being generated.

Since this issue and the fix for this bug touch the same function I have taken 
the liberty to submit a single PR for both.

Example failing before the fix (in Quidem format):
{code:java}
select t.dd, t.x
from dept d,
lateral (select d.deptno as dd, u.x
         from unnest(array[d.deptno + 100]) as u(x)) as t
where d.dname = 'SALES'; {code}
This fails before the fix with:
{code:java}
 Mappings$NoElementException: source #0 has no target in mapping{code}
 

> CorrelateProjectExtractor does not handle nested field accesses 
> cor0.field0.field1
> ----------------------------------------------------------------------------------
>
>                 Key: CALCITE-7646
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7646
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.42.0
>            Reporter: Mihai Budiu
>            Assignee: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>
> The decorrelator has a helper class called CorrelateProjectExtractor which 
> moves projections from the right side of a Correlate to the left side. 
> However, the helper ignores nested field accesses, assuming incorrectly that 
> any field access is an input field access. Such expressions should also be 
> moved to the left side.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to