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/07/28 09:22:02 UTC
[GitHub] [incubator-doris] wangshuo128 opened a new issue #6338: Fold constant in `timestamp` function
wangshuo128 opened a new issue #6338:
URL: https://github.com/apache/incubator-doris/issues/6338
This is a real-world situation from SQL generated by tableau.
Sometimes the date type partition column is compared with literal wraped by `timestamp` function. e.g.,
```SQL
SELECT * FROM tbl WHERE ...
AND (`date_partition_column` >= TIMESTAMP('2021-06-01 00:00:00'))
AND (`date_partition_column` < TIMESTAMP('2021-08-01 00:00:00'))
```
To reproduce, we create a table
```SQL
CREATE TABLE `t` (
`dt` date NULL COMMENT "",
`id` int(11) NULL COMMENT "",
`uv` int(11) SUM NULL COMMENT ""
) ENGINE=OLAP
AGGREGATE KEY(`dt`, `id`)
COMMENT "OLAP"
PARTITION BY RANGE(`dt`)
(PARTITION p20210722 VALUES [('2021-07-21'), ('2021-07-22')),
PARTITION p20210723 VALUES [('2021-07-22'), ('2021-07-23')),
PARTITION p20210724 VALUES [('2021-07-23'), ('2021-07-24')),
PARTITION p20210725 VALUES [('2021-07-24'), ('2021-07-25')),
PARTITION p20210726 VALUES [('2021-07-25'), ('2021-07-26')))
DISTRIBUTED BY HASH(`id`) BUCKETS 10
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "V2"
);
```
Then insert data
```SQL
insert into t select '2021-07-24' as dt, 1 as id, 2 as uv;
insert into t select '2021-07-24' as dt, 1 as id, 3 as uv;
insert into t select '2021-07-24' as dt, 2 as id, 1 as uv;
insert into t select '2021-07-25' as dt, 1 as id, 4 as uv;
insert into t select '2021-07-25' as dt, 2 as id, 8 as uv;
insert into t select '2021-07-23' as dt, 3 as id, 4 as uv;
```
Try the SQL below:
```SQL
-- This would scan all the partitions.
explain select * from t where dt >= TIMESTAMP('2021-07-24 00:00:00') and dt < TIMESTAMP('2021-07-25 00:00:00');
```
--
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] wangbo closed issue #6338: Fold constant in `timestamp` function
Posted by GitBox <gi...@apache.org>.
wangbo closed issue #6338:
URL: https://github.com/apache/incubator-doris/issues/6338
--
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