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

Adding a HAVING condition to a query with a dynamic parameter makes the result always empty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.27.0
    • 1.28.0
    • None

    Description

      The query

      SELECT sal, COUNT(1) AS count_val
      FROM emp t WHERE sal = ?
      GROUP BY sal HAVING sal < 1000 

      gets translated to the following logical plan:

      LogicalFilter(condition=[<($0, 1000)])
        LogicalAggregate(group=[{0}], COUNT_VAL=[COUNT()])
          LogicalProject(SAL=[$5], $f1=[1])
            LogicalFilter(condition=[=($5, ?0)])
              LogicalTableScan(table=[[CATALOG, SALES, EMP]]) 

      However, applying CoreRules.FILTER_REDUCE_EXPRESSIONS to the plan it just becomes

      LogicalValues(tuples=[[]]) 

       

      Attachments

        1. CALCITE-4848.patch
          4 kB
          Thomas Rebele

        Issue Links

          Activity

            People

              thomas.rebele Thomas Rebele
              thomas.rebele Thomas Rebele
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 40m
                  1h 40m