Skip to content

Evaluate Case When Expr in Fe when possible #3395

Description

@wangbo

In the query case partition column compare with a case when Expr, evaluate Case when Expr in Fe can void unnecessary partition scan.

See a example as below

SQL

select event_day,sum(pv) from table2 where event_day= case when date_format(now(),'%H%i') = 0 then 1 else 2 end group by event_day

BEFORE

 0:OlapScanNode |
| TABLE: table2 |
| PREAGGREGATION: ON |
| PREDICATES: `event_day` = CASE WHEN FALSE THEN 1 ELSE 2 END |
| partitions=1/3 |
| rollup: table2 |
| buckets=10/10 |
| cardinality=14 |
| avgRowSize=723.5714 |
| numNodes=1 |
| tuple ids: 0 

AFTER

 0:OlapScanNode |
| TABLE: table2 |
| PREAGGREGATION: ON |
| PREDICATES: `event_day` = 2.0 |
| partitions=1/3 |
| rollup: table2 |
| buckets=10/10 |
| cardinality=14 |
| avgRowSize=723.5714 |
| numNodes=1 |
| tuple ids: 0 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions