steadyBoy opened a new issue #7478: URL: https://github.com/apache/incubator-doris/issues/7478
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and found no similar issues. ### Version 0.15.1-rc09-d53cbef36 ### What's Wrong? **通过 ComputeNode 节点计算 SQL 中的常量表达式时(set enable_fold_constant_by_be=true), having 子句中不支持使用 now(), current_date() 等常量函数** _该问题在0.12等没有 “通过 ComputeNode 节点计算 SQL 中的常量表达式” 功能的版本不存在。_ **设置常量折叠为 true :** `mysql> set enable_fold_constant_by_be=true; Query OK, 0 rows affected (0.03 sec) mysql> explain -> SELECT year -> ,SUM(income) income_sum -> FROM having_test -> GROUP BY year -> having sum(case when NOW() = '2021-12-24' then 0 else income end) <> 0 -> ; ERROR 1064 (HY000): errCode = 2, detailMessage = Unexpected exception: null ` **设置常量折叠为 false:** ` mysql> set enable_fold_constant_by_be=false; Query OK, 0 rows affected (0.03 sec) mysql> explain -> SELECT year -> ,SUM(income) income_sum -> FROM having_test -> GROUP BY year -> having sum(case when NOW() = '2021-12-24' then 0 else income end) <> 0 -> ; +------------------------------------------------------------------------------------------+ | Explain String | +------------------------------------------------------------------------------------------+ | PLAN FRAGMENT 0 | | OUTPUT EXPRS:<slot 2> `year` | <slot 3> sum(`income`) | | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`having_test`.`income_month_key` | | | | RESULT SINK | | | | 1:AGGREGATE (update finalize) | | | output: sum(`income`) | | | group by: `year` | | | having: <slot 3> sum(`income`) != 0 | | | cardinality=-1 | | | | | 0:OlapScanNode | | TABLE: having_test | | PREAGGREGATION: OFF. Reason: conjunct on `year` which is StorageEngine value column | | partitions=0/1 | | rollup: null | | tabletRatio=0/0 | | tabletList= | | cardinality=0 | | avgRowSize=20.0 | | numNodes=1 | +------------------------------------------------------------------------------------------+ 22 rows in set (0.03 sec)` ### What You Expected? 通过 ComputeNode 节点计算 SQL 中的常量表达式(即设置 set enable_fold_constant_by_be=true) 时, having 子句中不支持使用 now(), currnet() 等常量函数。示例 SQL 如下: `SELECT year ,SUM(income) income_sum FROM having_test GROUP BY year having sum(case when NOW() = '2021-12-24' then 0 else income end) <> 0 ;` ### How to Reproduce? _No response_ ### Anything Else? _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org