apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.3k stars 3.21k forks source link

[Bug] partition prune error when partition condition value has some function #32363

Open Lif0820 opened 5 months ago

Lif0820 commented 5 months ago

Search before asking

Version

2.0.3 2.0.5

What's Wrong?

partition prune error when partition condition value with has function, such as: where time_key = substr('20240301000000', 1, 8)

What You Expected?

fix

How to Reproduce?

CREATE TABLE test_event_log ( device_id bigint(20) NULL, v1 double NULL, v2 double NULL, time_key int(11) NULL COMMENT 'yyyyMMdd', ) ENGINE=OLAP DUPLICATE KEY(device_id) COMMENT 'OLAP' PARTITION BY RANGE(time_key) ( PARTITION p202401 VALUES [("20240101"), ("20240201")), PARTITION p202402 VALUES [("20240201"), ("20240301")), PARTITION p202403 VALUES [("20240301"), ("20240401")), PARTITION p202404 VALUES [("20240401"), ("20240501"))) DISTRIBUTED BY HASH(device_id) BUCKETS 16 PROPERTIES ( "replication_allocation" = "tag.location.default: 3", "enable_single_replica_compaction" = "false" );

insert into test_event_log VALUES (1, 1, 1, 20240101); insert into test_event_log VALUES (2, 2, 2, 20240201); insert into test_event_log VALUES (3, 3, 2, 20240301);

explain select count(*) from test_event_log where time_key = substr('20240301000000', 1, 8) -- can not partition prune -- where time_key = cast('20240301' as bigint) -- can not partition prune -- where time_key = '20240301'; -- ok

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

Lif0820 commented 5 months ago

this issue happens when partition column is not a data/datatime type, such as bigint