924060929 commented on code in PR #70480:
URL: https://github.com/apache/doris/pull/70480#discussion_r4674776688
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java:
##########
@@ -225,6 +251,18 @@ public PhysicalFilter visitPhysicalFilter(PhysicalFilter<?
extends Plan> filter,
return filter;
}
+ @Override
+ public PhysicalOlapScan visitPhysicalOlapScan(PhysicalOlapScan scan,
CascadesContext context) {
+ if (scan.getTable() instanceof OlapChangelogTableWrapper) {
+ // Base-table statistics do not describe the stream's incremental
data.
+ context.getRuntimeFilterContext().addEffectiveSrcNode(scan,
Review Comment:
**[P2] Carry the changelog marker through storage aggregation**
Consider a hash join on `fact.k = b.n`, where `b` is `SELECT COUNT(*) AS n
FROM t@incr('incrementType'='MIN_DELTA')`. With ungrouped aggregate pushdown,
`PhysicalStorageLayerAggregate` holds the scan in `getRelation()`. Its
inherited visitor visits the scan, which gets `CHANGELOG` here, then returns
the unmarked aggregate. If `fact.k` has unknown statistics and cannot prune
partitions or buckets, the parent join can drop a runtime filter whose build
side contains just one value.
Please propagate `CHANGELOG` from the embedded relation to
`PhysicalStorageLayerAggregate` in the pruner. A regression test should assert
both that storage pushdown occurred and that the outer join kept its filter.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterContext.java:
##########
@@ -219,14 +219,15 @@ public void setTargetNullCount() {
}
/**
- * the selectivity produced by predicate or rf
+ * Effective source types in increasing priority for propagation.
*/
public enum EffectiveSrcType {
- NATIVE, REF
+ REF, NATIVE, CHANGELOG
}
public void addEffectiveSrcNode(Plan node, EffectiveSrcType type) {
- effectiveSrcNodes.put(node, type);
+ effectiveSrcNodes.merge(node, type,
Review Comment:
**[P2] Key effective sources by physical plan node identity**
`PhysicalLimit.equals()` compares limit, offset and phase, ignoring its
input. If this traversal visits `LIMIT 10` over a stream first, a separate
`LIMIT 10` over an ordinary table can hit the same `HashMap` entry. Registering
`NATIVE` for the ordinary limit then keeps the earlier `CHANGELOG`. A `UNION
ALL` containing that ordinary limit inherits the stream marker, so a join built
from entirely ordinary tables can retain a filter it would otherwise prune.
Please use an `IdentityHashMap<Plan, EffectiveSrcType>` for
`effectiveSrcNodes`. A test with equal limits on independent branches should
verify that the ordinary union stays unmarked in both visit orders.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java:
##########
@@ -79,27 +86,35 @@ public Plan visit(Plan plan, CascadesContext context) {
}
@Override
- public PhysicalRecursiveUnion visitPhysicalRecursiveUnion(
+ public PhysicalRecursiveUnion<? extends Plan, ? extends Plan>
visitPhysicalRecursiveUnion(
PhysicalRecursiveUnion<? extends Plan, ? extends Plan>
recursiveUnion, CascadesContext context) {
- for (Plan child : recursiveUnion.children()) {
- child.accept(this, context);
- }
+ visitChildrenAndPropagateChangelog(recursiveUnion, context);
Review Comment:
**[P2] Carry the incremental seed to the work table inside the recursive
term**
Suppose `walk` is seeded with IDs from a table stream and its recursive term
runs `edges e JOIN [broadcast] walk w ON e.parent_id = w.id`. On the first
iteration, `w` contains exactly the incremental IDs. This call marks the
recursive union's output, but the join inside the term reads a separate
`PhysicalWorkTableReference` leaf. Without a marker on that leaf, unknown
statistics on a non-partition, non-bucket `parent_id` can cause the inner join
to discard the filter on `edges`.
Please record the seed's source by recursive CTE ID before visiting the
recursive term, and apply it at the matching work-table reference. The
regression should assert that the join **inside** the recursive term keeps its
filter. The existing test checks the join above the union.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java:
##########
@@ -110,10 +125,12 @@ public PhysicalIntersect
visitPhysicalIntersect(PhysicalIntersect intersect, Cas
CascadesContext context) {
join.right().accept(this, context);
join.left().accept(this, context);
- if
(context.getRuntimeFilterContext().isEffectiveSrcNode(join.child(0))) {
- RuntimeFilterContext.EffectiveSrcType childType =
context.getRuntimeFilterContext()
- .getEffectiveSrcType(join.child(0));
- context.getRuntimeFilterContext().addEffectiveSrcNode(join,
childType);
+ RuntimeFilterContext rfContext = context.getRuntimeFilterContext();
+ if (rfContext.isEffectiveSrcNode(join.left())) {
+ rfContext.addEffectiveSrcNode(join,
rfContext.getEffectiveSrcType(join.left()));
+ }
+ if (join.getJoinType().isRemainRightJoin()) {
+ propagateChangelog(join, join.right(), rfContext);
Review Comment:
**[P2] Keep the right-side stream marker off preserved left keys**
Consider a parent hash join on `F.k = A.k` whose build input is `A LEFT JOIN
stream S`, with `S.payload` also selected. Whether `S` is empty or matches an
`A` row several times, the build still contains every `A.k`.
`isRemainRightJoin()` is true for `LEFT OUTER`, so this line marks the whole
join `CHANGELOG`. If `F` and `A` have the same non-null keys, the parent builds
and probes a filter that cannot reject a row. The hash-join propagation path
has the same issue.
Please use the parent filter's build expression to decide which source
applies across an outer join. A key from the preserved `A` side should keep its
ordinary pruning decision, while a key from `S` can inherit `CHANGELOG`. Please
cover both key origins for hash and nested-loop joins.
--
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]