Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6.0
    • Component/s: None
    • Labels:
      None

      Description

      Represent IN, NOT IN, EXISTS and scalar sub-queries as RexSubQuery extends RexNode. Then we can write a planner rule that expands sub-queries.

        Issue Links

          Activity

          Hide
          julianhyde Julian Hyde added a comment -

          When this issue is fixed, see whether the following are fixed: CALCITE-551, CALCITE-365, CALCITE-709, CALCITE-297.

          Show
          julianhyde Julian Hyde added a comment - When this issue is fixed, see whether the following are fixed: CALCITE-551 , CALCITE-365 , CALCITE-709 , CALCITE-297 .
          Hide
          julianhyde Julian Hyde added a comment -

          Vladimir Sitnikov, I'm finishing up this jira case and the output of EnumerableCorrelateTest.simpleCorrelate has changed. It looks to me like an improvement. Do you agree?

          Before:

          EnumerableCalc(expr#0..5=[{inputs}], expr#6=[IS NOT NULL($t5)], empid=[$t0], name=[$t2], $condition=[$t6])
            EnumerableCorrelate(correlation=[$cor0], joinType=[LEFT], requiredColumns=[{1}])
              EnumerableTableScan(table=[[s, emps]])
              EnumerableAggregate(group=[{}], agg#0=[MIN($0)])
                EnumerableCalc(expr#0..3=[{inputs}], expr#4=[true], expr#5=[$cor0], expr#6=[$t5.deptno], expr#7=[=($t0, $t6)], $f0=[$t4], $condition=[$t7])
                  EnumerableTableScan(table=[[s, depts]])
          

          After:

          EnumerableCalc(expr#0..4=[{inputs}], empid=[$t0], name=[$t2])
            EnumerableCorrelate(correlation=[$cor0], joinType=[INNER], requiredColumns=[{1}])
              EnumerableTableScan(table=[[s, emps]])
              EnumerableAggregate(group=[{}])
                EnumerableCalc(expr#0..3=[{inputs}], expr#4=[$cor0], expr#5=[$t4.deptno], expr#6=[=($t0, $t5)], proj#0..3=[{exprs}], $condition=[$t6])
                  EnumerableTableScan(table=[[s, depts]])
          

          It seems that FilterJoinRule has strengthened the join type because of the IS NOT NULL condition. The code is https://github.com/julianhyde/incubator-calcite/commit/d537922082715dcf2855a0b8314bdb6fcac94957.

          Show
          julianhyde Julian Hyde added a comment - Vladimir Sitnikov , I'm finishing up this jira case and the output of EnumerableCorrelateTest.simpleCorrelate has changed. It looks to me like an improvement. Do you agree? Before: EnumerableCalc(expr#0..5=[{inputs}], expr#6=[IS NOT NULL($t5)], empid=[$t0], name=[$t2], $condition=[$t6]) EnumerableCorrelate(correlation=[$cor0], joinType=[LEFT], requiredColumns=[{1}]) EnumerableTableScan(table=[[s, emps]]) EnumerableAggregate(group=[{}], agg#0=[MIN($0)]) EnumerableCalc(expr#0..3=[{inputs}], expr#4=[true], expr#5=[$cor0], expr#6=[$t5.deptno], expr#7=[=($t0, $t6)], $f0=[$t4], $condition=[$t7]) EnumerableTableScan(table=[[s, depts]]) After: EnumerableCalc(expr#0..4=[{inputs}], empid=[$t0], name=[$t2]) EnumerableCorrelate(correlation=[$cor0], joinType=[INNER], requiredColumns=[{1}]) EnumerableTableScan(table=[[s, emps]]) EnumerableAggregate(group=[{}]) EnumerableCalc(expr#0..3=[{inputs}], expr#4=[$cor0], expr#5=[$t4.deptno], expr#6=[=($t0, $t5)], proj#0..3=[{exprs}], $condition=[$t6]) EnumerableTableScan(table=[[s, depts]]) It seems that FilterJoinRule has strengthened the join type because of the IS NOT NULL condition. The code is https://github.com/julianhyde/incubator-calcite/commit/d537922082715dcf2855a0b8314bdb6fcac94957 .
          Hide
          julianhyde Julian Hyde added a comment -

          I'll answer my own question... it's giving the wrong answer, so clearly not an improvement.

          Show
          julianhyde Julian Hyde added a comment - I'll answer my own question... it's giving the wrong answer, so clearly not an improvement.
          Hide
          julianhyde Julian Hyde added a comment -

          Now the plan is

          EnumerableCalc(expr#0..5=[{inputs}], empid=[$t0], name=[$t2])
            EnumerableCorrelate(correlation=[$cor0], joinType=[INNER], requiredColumns=[{1}])
              EnumerableTableScan(table=[[s, emps]])
              EnumerableAggregate(group=[{0}])
                EnumerableCalc(expr#0..3=[{inputs}], expr#4=[true], expr#5=[$cor0], expr#6=[$t5.deptno], expr#7=[=($t0, $t6)], i=[$t4], $condition=[$t7])
                  EnumerableTableScan(table=[[s, depts]])

          and it gives the right answer. Vladimir Sitnikov, what do you think?

          Show
          julianhyde Julian Hyde added a comment - Now the plan is EnumerableCalc(expr#0..5=[{inputs}], empid=[$t0], name=[$t2]) EnumerableCorrelate(correlation=[$cor0], joinType=[INNER], requiredColumns=[{1}]) EnumerableTableScan(table=[[s, emps]]) EnumerableAggregate(group=[{0}]) EnumerableCalc(expr#0..3=[{inputs}], expr#4=[true], expr#5=[$cor0], expr#6=[$t5.deptno], expr#7=[=($t0, $t6)], i=[$t4], $condition=[$t7]) EnumerableTableScan(table=[[s, depts]]) and it gives the right answer. Vladimir Sitnikov , what do you think?
          Hide
          vladimirsitnikov Vladimir Sitnikov added a comment - - edited

          Will check in a couple of days.

          Show
          vladimirsitnikov Vladimir Sitnikov added a comment - - edited Will check in a couple of days.
          Hide
          julianhyde Julian Hyde added a comment -

          Vladimir Sitnikov, I'm taking this back because I'm actively working on this. See https://github.com/julianhyde/calcite/commits/816-sub-query. What work did you want to do on this?

          Show
          julianhyde Julian Hyde added a comment - Vladimir Sitnikov , I'm taking this back because I'm actively working on this. See https://github.com/julianhyde/calcite/commits/816-sub-query . What work did you want to do on this?
          Show
          julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/505a9064 .
          Hide
          julianhyde Julian Hyde added a comment -

          Resolved in release 1.6.0 (2016-01-22).

          Show
          julianhyde Julian Hyde added a comment - Resolved in release 1.6.0 (2016-01-22).

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              julianhyde Julian Hyde
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development