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

Do not add SINGLE_VALUE aggregate function to a sub-query that will never return more than one row

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.0-incubating
    • 1.3.0-incubating
    • None
    • None

    Description

      In the following query, the subquery is producing a scalar value but the logical plan still creates a SqlSingleValueAggFunction.

      select r_regionkey from region
         where r_regionkey > (select min(n_regionkey) * 2 from nation);
      

      If the aggregate is just min(n_regionkey) instead of the expression min(n_regionkey) * 2 then no SqlSingleValueAggFunction is created. Ideally, both should behave the same.

      This is not necessarily a bug but it does create a burden on the underlying execution engine to support this function even in cases where it may not be needed.

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            amansinha100 Aman Sinha
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: