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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.0-incubating
    • Fix Version/s: 1.5.0
    • Component/s: None
    • Labels:
      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]])
      
      1. CALCITE-894_2.patch
        8 kB
        Maryann Xue
      2. CALCITE-894.patch
        4 kB
        Maryann Xue

        Activity

        Hide
        maryannxue Maryann Xue added a comment -

        Updated ref for another 4 tests affected.

        Show
        maryannxue Maryann Xue added a comment - Updated ref for another 4 tests affected.
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/c6cc5a77 . Thanks for the PR, Maryann Xue !
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Resolved in release 1.5.0 (2015-11-10)

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.5.0 (2015-11-10)

          People

          • Assignee:
            maryannxue Maryann Xue
            Reporter:
            maryannxue Maryann Xue
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development