[ https://issues.apache.org/jira/browse/CALCITE-4848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17428573#comment-17428573 ]
Chunwei Lei commented on CALCITE-4848: -------------------------------------- The PR looks good to me. > Adding a HAVING condition to a query with a dynamic parameter makes the > result always 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 > Assignee: Thomas Rebele > Priority: Major > Labels: pull-request-available > Fix For: 1.28.0 > > Attachments: CALCITE-4848.patch > > Time Spent: 1.5h > Remaining Estimate: 0h > > 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)