englefly opened a new pull request, #66905:
URL: https://github.com/apache/doris/pull/66905
### What problem does this PR solve?
Problem Summary:
A CTE that defines a single constant row (e.g. `WITH params AS (SELECT
CAST(...) AS
begin_time, ...)`) is inlined into its consumers as a one-row relation, but
the constant
projects were only registered as uniform slots without values. Constant
propagation and
predicate inference outside the relation therefore could not substitute the
constant
values into predicates over the CTE columns, so predicates like
`dt BETWEEN DATE_SUB(params.begin_time, INTERVAL params.period_days DAY) AND
DATE_SUB(params.begin_time, INTERVAL 1 DAY)` were not folded, the `dt`
predicates were
left as nested-loop-join conjuncts with runtime filters, and partition
pruning failed:
the scan read all 526/537 partitions instead of the single needed partition.
Fix:
`LogicalOneRowRelation.computeUniform` now registers the values of constant
projects as
uniform constants, so constant propagation can substitute them into
predicates over the
CTE columns, fold functions such as DATE_SUB over them, and push the
resulting
predicates into the scan for partition pruning.
### Release note
None
### Check List (For Author)
- Test: FE unit test ConstantCteTest (asserts both scans prune to the
expected single
partition); regression test test_constant_cte_partition_prune.
- Behavior changed: No
- Does this need documentation: No
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]