seawinde opened a new pull request, #38527:
URL: https://github.com/apache/doris/pull/38527

   ## Proposed changes
   
   Support to partition prune when query rewrite by sync materialized view
   such as table def is as following:
   ```sql
           CREATE TABLE IF NOT EXISTS test_unique (
           `time` DATETIME NULL COMMENT '查询时间', 
           `app_name` VARCHAR(64) NULL COMMENT '标识', 
           `event_id` VARCHAR(128) NULL COMMENT '标识', 
           `decision` VARCHAR(32) NULL COMMENT '枚举值', 
           `id` VARCHAR(35) NOT NULL COMMENT 'od', 
           `code` VARCHAR(64) NULL COMMENT '标识', 
           `event_type` VARCHAR(32) NULL COMMENT '事件类型' 
           )
           UNIQUE KEY(time)
           PARTITION BY RANGE(time)                                             
                                                                                
                                                                                
   
           (                                                                    
                                                                                
                                                                                
  
            FROM ("2024-07-01 00:00:00") TO ("2024-07-15 00:00:00") INTERVAL 1 
HOUR                                                                            
                                                                                
                  
           )     
           DISTRIBUTED BY HASH(time)
           BUCKETS 3 PROPERTIES ("replication_num" = "1");
   ```
   sync materialized view def is
   
   ```sql
   create materialized view as
       select
       app_name,
       event_id,
       time,
       count(*)
       from 
       test_duplicate
       group by
       app_name,
       event_id,
       time;
   ```
   
   if your query is following, if rewritten by sync materialized view 
successfully, should partition prune
   ```sql
       select
       app_name,
       event_id,
       time,
       count(*)
       from 
       test_duplicate
       where time < '2024-07-05 01:00:00'
       group by
       app_name,
       time,
       event_id;
   
   ```
   
   
   
   


-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to