xinyiZzz opened a new issue #6296:
URL: https://github.com/apache/incubator-doris/issues/6296


   **To Reproduce**
   Table building statement
   ```
   CREATE TABLE LINEORDER3 
   ( t1 BIGINT, t2 BIGINT) 
   ENGINE=OLAP
   AGGREGATE KEY(`t1`, `t2`) 
   PARTITION BY RANGE(`t2`)
   (PARTITION p20210101 VALUES [("-2147483648"), ("20210102")),
   PARTITION p20210102 VALUES [("20210102"), ("20210103")),
   PARTITION p20210103 VALUES [("20210103"), ("20210104")))
   DISTRIBUTED BY HASH(t2) BUCKETS 10
   PROPERTIES("replication_num" = "1", "storage_format" = "DEFAULT");
   ```
   
   If the condition of the partition column contains `OR`, the partition cannot 
be hit, and the entire table will be scanned.
   ```
   explain SELECT t2
   FROM LINEORDER3 
   WHERE t2 = 20210101 OR t2 = 20210102;
   
   |      0:OlapScanNode                                                        
         |
   |      TABLE: LINEORDER3                                                     
      |
   |      PREAGGREGATION: OFF. Reason: No AggregateInfo                         
      |
   |      PREDICATES: (`t2` = 20210101) OR (`t2` = 20210102)                    
      |
   |      partitions=3/3                                                        
      |
   |      rollup: LINEORDER3                                                    
      |
   |      tabletRatio=30/30
   ```
   
   `IN` can hit the partition
   ```
   explain SELECT t2
   FROM LINEORDER3 
   WHERE t2 in (20210101, 20210102);
   
   |   0:OlapScanNode                                                           
      |
   |      TABLE: LINEORDER3                                                     
      |
   |      PREAGGREGATION: OFF. Reason: No AggregateInfo                         
      |
   |      PREDICATES: `t2` IN (20210101, 20210102)                              
      |
   |      partitions=2/3                                                        
      |
   |      rollup: LINEORDER3                                                    
      |
   |      tabletRatio=4/20                                                      
      |
   ```
   
   **Background**
   In the user's production environment, there are business requirements that 
need to combine the `AND` and `OR` conditions to group condition queries, 
similar to:
   ```
   SELECT userid 
   FROM test_table
   WHERE event_day = '2021-05-20' AND userid = 31050828 
       OR event_day = '2021-05-19' AND userid = 31050832;
   ```
   
   At present, users are guided to bypass this problem through `union all`, so 
SQL will be more cumbersome, consider supporting the `OR` condition to hit the 
partition?
   ```
   explain SELECT userid 
   FROM test_table 
   WHERE event_day = '2021-05-18' AND userid = 31050828
   
   union all
   
   SELECT userid 
   FROM test_table 
   WHERE event_day = '2021-05-19' AND userid = 31050832;
   ```


-- 
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]

Reply via email to