yongjinhou opened a new issue, #39800: URL: https://github.com/apache/doris/issues/39800
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version 2.0.12 ### What's Wrong? with+union all(两个union all)查询时,会扫描全表,且explain查看显示的分区数与实际不符合。只使用一个union all正常命中分区。 <img width="1385" alt="image" src="https://github.com/user-attachments/assets/0296b061-29ec-4b61-8c0e-0c2ea43ebe0d"> ### What You Expected? with+union all(两个union all)查询时,命中分区,且explain查看显示的分区数与实际符合 ### How to Reproduce? 1. 建表 `CREATE TABLE temp_table ( `id` BIGINT NOT NULL COMMENT '主键', `create_time` DATETIME NOT NULL DEFAULT "2022-02-02 00:00:00" COMMENT '时间', `user_id` VARCHAR(200) NOT NULL DEFAULT "0" COMMENT 'id', ) ENGINE=OLAP UNIQUE KEY(`id`, `create_time`) COMMENT 'OLAP' PARTITION BY RANGE(`create_time`) (PARTITION p20240816 VALUES [('2024-08-16 00:00:00'), ('2024-08-17 00:00:00')), PARTITION p20240817 VALUES [('2024-08-17 00:00:00'), ('2024-08-18 00:00:00')), PARTITION p20240818 VALUES [('2024-08-18 00:00:00'), ('2024-08-19 00:00:00')), PARTITION p20240819 VALUES [('2024-08-19 00:00:00'), ('2024-08-20 00:00:00')), PARTITION p20240820 VALUES [('2024-08-20 00:00:00'), ('2024-08-21 00:00:00')), PARTITION p20240821 VALUES [('2024-08-21 00:00:00'), ('2024-08-22 00:00:00')), PARTITION p20240822 VALUES [('2024-08-22 00:00:00'), ('2024-08-23 00:00:00')) ) DISTRIBUTED BY HASH(`id`) BUCKETS 10 PROPERTIES ( "replication_allocation" = "tag.location.default: 3", "is_being_synced" = "false", "dynamic_partition.enable" = "true", "dynamic_partition.time_unit" = "DAY", "dynamic_partition.time_zone" = "Asia/Shanghai", "dynamic_partition.start" = "-7", "dynamic_partition.end" = "2", "dynamic_partition.prefix" = "p", "dynamic_partition.replication_allocation" = "tag.location.default: 3", "dynamic_partition.buckets" = "32", "dynamic_partition.create_history_partition" = "false", "dynamic_partition.history_partition_num" = "-1", "dynamic_partition.hot_partition_num" = "0", "dynamic_partition.reserved_history_periods" = "NULL", "dynamic_partition.storage_policy" = "", "storage_format" = "V2", "disable_auto_compaction" = "false", "enable_single_replica_compaction" = "false" ); ` 2. 导入数据 `insert into temp_table values ("1051182595","2024-08-16 00:00:45","350517153"), ("1051183983","2024-08-17 00:00:07","267196587"), ("1051187293","2024-08-18 00:00:06","59146646"), ("1051187696","2024-08-19 00:00:09","304281816"), ("1051183990","2024-08-20 00:00:18","661291016"), ("1051186204","2024-08-21 00:00:12","662504607"), ("1051185604","2024-08-22 00:00:32","207718645");` 3. 查看执行计划 `with t0 as ( select user_id,create_time FROM temp_table ) SELECT create_time FROM ( SELECT * FROM t0 WHERE create_time >= DATE_FORMAT(NOW(), '%Y-%m-%d') UNION ALL SELECT * FROM t0 WHERE create_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 DAY), '%Y-%m-%d') AND create_time < DATE_FORMAT(NOW(), '%Y-%m-%d') UNION ALL SELECT * FROM t0 WHERE create_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 5 DAY), '%Y-%m-%d') AND create_time < DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 4 DAY), '%Y-%m-%d') ) tmp;` ### Anything Else? 无 ### 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
