Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-894

Do not generate redundant column alias for the left relation when translating IN subquery

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.4.0-incubating
    • 1.5.0
    • None
    • None

    Description

      select * from "hr"."emps" where "deptno" in (
        select "deptno" from "hr"."depts")
      

      would be converted into

      LogicalProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])
        LogicalJoin(condition=[=($5, $6)], joinType=[inner])
          LogicalProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$1])
            EnumerableTableScan(table=[[hr, emps]])
          LogicalAggregate(group=[{0}])
            LogicalProject(deptno=[$0])
              EnumerableTableScan(table=[[hr, depts]])
      

      There is an additional "$f5=[$1]" in the LogicalProject, which might cause us trouble in the later optimization stage. For example if "emps" table had a collation trait on $1, the Project would have multiple collation traits and would be flattened.
      Instead, we want the converted rel to be like:

      LogicalProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])
        LogicalJoin(condition=[=($1, $5)], joinType=[inner])
          EnumerableTableScan(table=[[hr, emps]])
          LogicalAggregate(group=[{0}])
            LogicalProject(deptno=[$0])
              EnumerableTableScan(table=[[hr, depts]])
      

      Attachments

        1. CALCITE-894.patch
          4 kB
          Wei Xue
        2. CALCITE-894_2.patch
          8 kB
          Wei Xue

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            maryannxue Wei Xue
            maryannxue Wei Xue
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment