You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/12/24 05:02:05 UTC
[GitHub] [incubator-doris] steadyBoy opened a new issue #7478: [Bug] having 子句不支持 now(), current_date() 等常量函数
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-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] jackwener commented on issue #7478: [Bug] having 子句不支持 now(), current_date() 等常量函数
Posted by GitBox <gi...@apache.org>.
jackwener commented on issue #7478:
URL: https://github.com/apache/incubator-doris/issues/7478#issuecomment-1001135185
```sql
CREATE TABLE `having_test` (
`date_key` date NOT NULL DEFAULT "1970-01-01" COMMENT "日期键",
`year` int(11) NOT NULL DEFAULT "1970" COMMENT "年份",
`income` decimal(9, 2) NOT NULL DEFAULT '0.00' COMMENT "收入"
) ENGINE=OLAP
DUPLICATE KEY(`date_key`, `year`)
DISTRIBUTED BY HASH(`date_key`) BUCKETS 2
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
);
```
```sql
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;
```
I successfully reproduce this Bug, it's certain a bug.
--
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-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] qidaye commented on issue #7478: [Bug] having 子句不支持 now(), current_date() 等常量函数
Posted by GitBox <gi...@apache.org>.
qidaye commented on issue #7478:
URL: https://github.com/apache/incubator-doris/issues/7478#issuecomment-1001501218
It's a bug. I'll fix it.
Thanks for reporting.
--
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-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] yangzhg closed issue #7478: [Bug] having 子句不支持 now(), current_date() 等常量函数
Posted by GitBox <gi...@apache.org>.
yangzhg closed issue #7478:
URL: https://github.com/apache/incubator-doris/issues/7478
--
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-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org