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;
   ![2020-10-17 
20-44-01屏幕截图](https://user-images.githubusercontent.com/12771191/96337427-b9f88c00-10b9-11eb-864d-56bdfe80e295.png)
   explain select day from test where 'hello' = day;
   ![2020-10-17 
20-44-26屏幕截图](https://user-images.githubusercontent.com/12771191/96337439-cbda2f00-10b9-11eb-9a24-be0c308b9d85.png)
   4. if day is valid, it will scan some partitions
   ![2020-10-17 
20-50-19屏幕截图](https://user-images.githubusercontent.com/12771191/96337520-62a6eb80-10ba-11eb-95b9-dc8adda90830.png)
   
   
   **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]

Reply via email to