Skip to content

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

@ryanzryu

Description

@ryanzryu

Search before asking

  • 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions