doris icon indicating copy to clipboard operation
doris copied to clipboard

[Bug] predicate can't push down when query cantain ‘union all’

Open ryanzryu opened this issue 1 year ago • 2 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Version

2.0 2.1

What's Wrong?

I have query like this: WITH x AS ( SELECT a.tz_name, a.ddate FROM 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 when I add this condition,ddate field condition don't push down on longer: image

in the other way, two condition can push down if delete UNION ALL 👍 image

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(20) NULL, time_zone varchar(65533) NULL, zone_offset varchar(65533) NULL, tz_name varchar(65533) 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", "is_being_synced" = "false", "storage_format" = "V2", "light_schema_change" = "true", "disable_auto_compaction" = "false", "enable_single_replica_compaction" = "false" );

insert into dim_time_zone_range values('2024-04-30',123,'UTC-8','+8','东八区','2024-04-30',2024-04-30);

query: WITH x AS ( SELECT a.tz_name, a.ddate FROM 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

ryanzryu avatar May 24 '24 11:05 ryanzryu

after PR #35463, there are still some remaining issues that have not been addressed. For example, when the number of consumers is optimized below the inline threshold, they cannot be inlined correctly. Additionally, when there is only one consumer left, the filter of that consumer is not eliminated.

morrySnow avatar May 27 '24 11:05 morrySnow

您的邮件我已收到。

ryanzryu avatar May 27 '24 11:05 ryanzryu