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

SubQueryRemoveRule should create Correlate, not Join, for correlated sub-queries

    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

      In some cases of FILTER correlated subqueries, the "variablesSet" didn't get passed down to RelBuilder.join() and thus a Join rel was created while it should have been a Correlate rel.
      For example,

      select order_id, quantity from orders o
      where quantity = (
          select max(quantity) from orders o2
          where o.item_id = o2.item_id)
      

      Does the same apply to PROJECT and JOIN subqueries, Julian Hyde ?

      1. CALCITE-1055_2.patch
        4 kB
        Maryann Xue
      2. CALCITE-1055.patch
        1 kB
        Maryann Xue

        Issue Links

          Activity

          Hide
          julianhyde Julian Hyde added a comment -

          Is this a duplicate of CALCITE-559? Its test case JdbcTest.testJoinCorreScalarSubQ looks very similar.

          Show
          julianhyde Julian Hyde added a comment - Is this a duplicate of CALCITE-559 ? Its test case JdbcTest.testJoinCorreScalarSubQ looks very similar.
          Hide
          maryannxue Maryann Xue added a comment -

          No. This one was broken by CALCITE-816. We test correlated subqueries un-decorrelated in order to verify that runtime of nested loop join and they always worked. CALCITE-559 might be dup of CALCITE-864, which is "correlated subquery" + "join".

          Show
          maryannxue Maryann Xue added a comment - No. This one was broken by CALCITE-816 . We test correlated subqueries un-decorrelated in order to verify that runtime of nested loop join and they always worked. CALCITE-559 might be dup of CALCITE-864 , which is "correlated subquery" + "join".
          Hide
          maryannxue Maryann Xue added a comment -

          Updating the patch with one test case.

          Show
          maryannxue Maryann Xue added a comment - Updating the patch with one test case.
          Show
          julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/cecef9d3 .
          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:
              maryannxue Maryann Xue
              Reporter:
              maryannxue Maryann Xue
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development