ryanzryu opened a new issue, #35379:
URL: https://github.com/apache/doris/issues/35379

   ### 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
   
   master
   
   ### What's Wrong?
   
   I have query like this:
   WITH x AS (
     SELECT 
       a.tz_name, 
       a.ddate 
     FROM 
       `default_cluster:dim_osgame_base`.`dim_time_zone_range` a
   ) 
   select 
     * 
   from 
     (
       select 
         `tz_name`, 
         ddate 
       from 
         x 
       UNION ALL 
       select 
         '99999' AS `tz_name`, 
         ddate 
       from 
         x
     ) tmp 
   where 
     tmp.ddate = '2024-04-30' 
     AND tmp.tz_name = '东八区'
   
   when I delete  “tmp.tz_name = '东八区'” condition,doris nereids plan like this:
   
![image](https://github.com/apache/doris/assets/143597717/bb6c56fc-ce4f-44ac-97e2-38dfa309add9)
   when I add this condition,ddate field condition don't push down on longer:
   
![image](https://github.com/apache/doris/assets/143597717/b2fa6349-34b0-45b7-9608-dcb570ad687a)
   
   in the other way,  two condition can push down if delete UNION ALL 👍 
   
![image](https://github.com/apache/doris/assets/143597717/7b3f80e2-cd36-4f33-9d43-d224e190c1e2)
   
   
   
   ### What You Expected?
   
   ddate field condition can push down when this query has union all statment
   
   ### How to Reproduce?
   
   DDL:
   CREATE TABLE `dim_time_zone_range` (
     `ddate` DATE NULL,
     `id` BIGINT NULL,
     `time_zone` VARCHAR(*) NULL,
     `zone_offset` VARCHAR(*) NULL,
     `tz_name` VARCHAR(*) NULL,
     `start_time` DATETIME NULL,
     `end_time` DATETIME NULL
   ) ENGINE=OLAP
   UNIQUE KEY(`ddate`, `id`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`ddate`) BUCKETS 16
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 3",
   "min_load_replica_num" = "-1",
   "is_being_synced" = "false",
   "storage_medium" = "hdd",
   "storage_format" = "V2",
   "inverted_index_storage_format" = "V1",
   "enable_unique_key_merge_on_write" = "true",
   "light_schema_change" = "true",
   "disable_auto_compaction" = "false",
   "enable_single_replica_compaction" = "false",
   "group_commit_interval_ms" = "10000",
   "group_commit_data_bytes" = "134217728"
   ); 
   query:
   WITH x AS (
     SELECT 
       a.tz_name, 
       a.ddate 
     FROM 
       `default_cluster:dim_osgame_base`.`dim_time_zone_range` a
   ) 
   select 
     * 
   from 
     (
       select 
         `tz_name`, 
         ddate 
       from 
         x 
       UNION ALL 
       select 
         '99999' AS `tz_name`, 
         ddate 
       from 
         x
     ) tmp 
   where 
     tmp.ddate = '2024-04-30' 
     AND tmp.tz_name = '东八区'
   
   
   
   ### Anything Else?
   
   _No response_
   
   ### 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: commits-unsubscr...@doris.apache.org.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