You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Thomas Rebele (Jira)" <ji...@apache.org> on 2021/10/12 12:43:00 UTC

[jira] [Created] (CALCITE-4848) Adding a HAVING condition to a query with a dynamic parameter makes the result empty

Thomas Rebele created CALCITE-4848:
--------------------------------------

             Summary: Adding a HAVING condition to a query with a dynamic parameter makes the result empty
                 Key: CALCITE-4848
                 URL: https://issues.apache.org/jira/browse/CALCITE-4848
             Project: Calcite
          Issue Type: Bug
    Affects Versions: 1.27.0
            Reporter: Thomas Rebele
         Attachments: CALCITE-4848.patch

The query
{code:java}
SELECT sal, COUNT(1) AS count_val
FROM emp t WHERE sal = ?
GROUP BY sal HAVING sal < 1000 {code}
gets translated to the following logical plan:
{code:java}
LogicalFilter(condition=[<($0, 1000)])
  LogicalAggregate(group=[{0}], COUNT_VAL=[COUNT()])
    LogicalProject(SAL=[$5], $f1=[1])
      LogicalFilter(condition=[=($5, ?0)])
        LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
However, applying CoreRules.FILTER_REDUCE_EXPRESSIONS to the plan it just becomes
{code:java}
LogicalValues(tuples=[[]]) {code}
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)