Details

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

      Description

      Calcite SQL-to-rel translator cannot handle a sub-query inside an aggregate function. An example is SqlToRelConverterTest.testAggCaseInSubquery:

      SELECT SUM(
        CASE WHEN deptno IN (SELECT deptno FROM dept) THEN 1
        ELSE 0 END)
      FROM emp

      Similar issue CALCITE-516 involves IN with constant list inside an aggregate function, which is treated similarly to a sub-query but is simpler.

        Issue Links

          Activity

          Hide
          julianhyde Julian Hyde added a comment -

          As part of fixing this issue, add back the assert that was removed as part of fixing CALCITE-516. The assert was and is valid. I removed it out of pragmatism: I'd rather not wait til we have full sub-query support before we support scalar IN in aggregate functions.

          Show
          julianhyde Julian Hyde added a comment - As part of fixing this issue, add back the assert that was removed as part of fixing CALCITE-516 . The assert was and is valid. I removed it out of pragmatism: I'd rather not wait til we have full sub-query support before we support scalar IN in aggregate functions.
          Hide
          vladimirsitnikov Vladimir Sitnikov added a comment -

          What if scalar subquery is translated to Correlate expression?

          Show
          vladimirsitnikov Vladimir Sitnikov added a comment - What if scalar subquery is translated to Correlate expression?
          Hide
          julianhyde Julian Hyde added a comment -

          That would be one way – a good way – to implement queries like this. Right now SQL-to-rel gets really tangled up when it sees a sub-query in an aggregate, so it doesn't get as far as decorrelation.

          Show
          julianhyde Julian Hyde added a comment - That would be one way – a good way – to implement queries like this. Right now SQL-to-rel gets really tangled up when it sees a sub-query in an aggregate, so it doesn't get as far as decorrelation.
          Hide
          julianhyde Julian Hyde added a comment -

          Seems to be fixed by CALCITE-864 fix. Added test cases in http://git-wip-us.apache.org/repos/asf/calcite/commit/82b58604.

          Show
          julianhyde Julian Hyde added a comment - Seems to be fixed by CALCITE-864 fix. Added test cases in http://git-wip-us.apache.org/repos/asf/calcite/commit/82b58604 .
          Hide
          julianhyde Julian Hyde added a comment -

          Resolved in release 1.7.0 (2016-03-22).

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development