xinghuayu007 opened a new issue #4755:
URL: https://github.com/apache/incubator-doris/issues/4755
**Describe the bug**
`select day from test where day='2020-10-32'`, table 'test' is parititioned
by day. In this case, '2020-10-32' will be taken as CastExpr not LiteralExpr,
and condition "day='2020-10-32'" will not be recognized as partitionfilter.
This case will scan all partitions. To avoid scall all partitions, it is better
to filter invalid date value.
**To Reproduce**
Steps to reproduce the behavior:
1. create table:
CREATE TABLE `test` (
`date` datetime NULL COMMENT "日期",
`day` date NULL COMMENT "",
`app_id` varchar(1000) NULL COMMENT "",
`device_id` int(11) 0 comment ""
) ENGINE=OLAP
DUPLICATE KEY(`date`, `day`, `app_id`)
COMMENT "OLAP"
PARTITION BY RANGE(`day`)()
DISTRIBUTED BY HASH(`device_id`) BUCKETS 64
PROPERTIES (
"replication_num" = "1",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"dynamic_partition.start" = "-30",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"dynamic_partition.replication_num" = "1",
"dynamic_partition.buckets" = "32",
"in_memory" = "false",
"storage_format" = "V2"
);
2. insert some data into each partition
3. execute a query which day is invalid, it will scan all partitions
explain select day from test where '2020-10-32' = day;

explain select day from test where 'hello' = day;

4. if day is valid, it will scan some partitions

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]