You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jin xing (Jira)" <ji...@apache.org> on 2019/10/08 13:53:00 UTC

[jira] [Comment Edited] (CALCITE-3390) ITEM expression does not get pushed to the right input of left-outer-join

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

jin xing edited comment on CALCITE-3390 at 10/8/19 1:52 PM:
------------------------------------------------------------

A test case for reproduction 
{code:java}
@Test public void test() {
  HepProgram program = new HepProgramBuilder()
      .addRuleInstance(ProjectJoinTransposeRule.INSTANCE)
      .build();

  checkPlanning(program, "" +
    "select B.col2['k1']\n" +
    "from\n" +
    "(select 1 col0, 2 col1, map['k1','v1','k2','v2'] col2) A\n" +
    "left join\n" +
    "(select 1 col0, 2 col1, map['k1','v1','k2','v2'] col2) B\n" +
    "on A.col0 = B.col0");
}

Result Plan as Below:
LogicalProject(EXPR$0=[ITEM($2, 'k1')])
  LogicalJoin(condition=[=($0, $1)], joinType=[left])
    LogicalProject(COL0=[$0])
      LogicalProject(COL0=[1], COL1=[2], COL2=[MAP('k1', 'v1', 'k2', 'v2')])
        LogicalValues(tuples=[[{ 0 }]])
    LogicalProject(COL0=[$0], COL2=[$2])
      LogicalProject(COL0=[1], COL1=[2], COL2=[MAP('k1', 'v1', 'k2', 'v2')])
        LogicalValues(tuples=[[{ 0 }]]){code}
SqlKind of ITEM is OTHER_FUNCTION, thus the Policy for checking Strong-ness is not ANY but AS_IS. Shall we add an independent SqlKind for it ? And set the Strong-ness checking Policy to be ANY.

 

 


was (Author: jinxing6042@126.com):
A test case for reproduction

 
{code:java}
@Test public void test() {
  HepProgram program = new HepProgramBuilder()
      .addRuleInstance(ProjectJoinTransposeRule.INSTANCE)
      .build();

  checkPlanning(program, "" +
    "select B.col2['k1']\n" +
    "from\n" +
    "(select 1 col0, 2 col1, map['k1','v1','k2','v2'] col2) A\n" +
    "left join\n" +
    "(select 1 col0, 2 col1, map['k1','v1','k2','v2'] col2) B\n" +
    "on A.col0 = B.col0");
}

Result Plan as Below:
LogicalProject(EXPR$0=[ITEM($2, 'k1')])
  LogicalJoin(condition=[=($0, $1)], joinType=[left])
    LogicalProject(COL0=[$0])
      LogicalProject(COL0=[1], COL1=[2], COL2=[MAP('k1', 'v1', 'k2', 'v2')])
        LogicalValues(tuples=[[{ 0 }]])
    LogicalProject(COL0=[$0], COL2=[$2])
      LogicalProject(COL0=[1], COL1=[2], COL2=[MAP('k1', 'v1', 'k2', 'v2')])
        LogicalValues(tuples=[[{ 0 }]]){code}
SqlKind of ITEM is OTHER_FUNCTION, thus the Policy for checking Strong-ness is not ANY but AS_IS. Shall we add an independent SqlKind for it ? And set the Strong-ness checking Policy to be ANY.

 

 

> ITEM expression does not get pushed to the right input of left-outer-join
> -------------------------------------------------------------------------
>
>                 Key: CALCITE-3390
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3390
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.21.0
>            Reporter: Aman Sinha
>            Assignee: Aman Sinha
>            Priority: Major
>
> In the following query, the ITEM expression above the Left Outer Join does not get pushed to the right input (null-preserving input) of the join whereas it should since ITEM does not change the nullability.  
> {noformat}
> explain plan without implementation for select tt7.columns[0], tt8.columns[0] as x from tt7 left outer join tt8  on tt7.columns[0] = tt8.columns[0];
>  DrillScreenRel
>   DrillProjectRel(EXPR$0=[$1], x=[ITEM($2, 0)])
>     DrillJoinRel(condition=[=($0, $3)], joinType=[left])
>       DrillProjectRel($f2=[ITEM($0, 0)], ITEM=[ITEM($0, 0)])
>         DrillScanRel(table=[[dfs, tmp, tt7]], groupscan=[EasyGroupScan [selectionRoot=file:/tmp/tt7, numFiles=1, columns=[`columns`[0]], files=[file:/tmp/tt7/0_0_0.csv]]])
>       DrillProjectRel(columns=[$0], $f2=[ITEM($0, 0)])
>         DrillScanRel(table=[[dfs, tmp, tt8]], groupscan=[EasyGroupScan [selectionRoot=file:/tmp/tt8, numFiles=1, columns=[`columns`, `columns`[0]], files=[file:/tmp/tt8/0_0_0.csv]]])
> {noformat}
> From what I can tell, the change in behavior occurred with CALCITE-1753; before that the ITEM was pushed on both sides of the Left Outer Join. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)