github-actions[bot] commented on code in PR #62527:
URL: https://github.com/apache/doris/pull/62527#discussion_r3086552049
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/HyperGraphComparator.java:
##########
@@ -254,21 +254,30 @@ private boolean canEliminateViewEdge(JoinEdge joinEdge) {
}
private boolean tryEliminateNodesAndEdge() {
- boolean hasFilterEdgeAbove = viewHyperGraph.getFilterEdges().stream()
- .filter(e -> LongBitmap.getCardinality(e.getReferenceNodes())
== 1)
- .anyMatch(e -> LongBitmap.isSubset(e.getReferenceNodes(),
shouldEliminateViewNodesMap));
- if (hasFilterEdgeAbove) {
- // If there is some filter edge above the eliminated node, we
should rebuild a plan
- // Right now, just reject it.
- return false;
- }
long allCanEliminateNodes = 0;
for (JoinEdge joinEdge : viewHyperGraph.getJoinEdges()) {
long canEliminateSideNodes = getCanEliminateSideNodes(joinEdge);
allCanEliminateNodes = LongBitmap.or(allCanEliminateNodes,
canEliminateSideNodes);
- if (LongBitmap.isOverlap(canEliminateSideNodes,
reservedShouldEliminatedViewNodes)
- && !canEliminateViewEdge(joinEdge)) {
- return false;
+ long shouldEliminateNodesOnCurrentEdge =
+ LongBitmap.newBitmapIntersect(canEliminateSideNodes,
reservedShouldEliminatedViewNodes);
+ if (LongBitmap.isOverlap(canEliminateSideNodes,
reservedShouldEliminatedViewNodes)) {
+ // For FilterEdge, leftChildEdges records join edges below the
filter child. Non-empty means
+ // the filter is above a join result, e.g. WHERE after LEFT
JOIN, and may filter preserved rows.
+ // Empty means the filter stays inside a base/nullable-side
subtree, which is safe for LOJ.
Review Comment:
`FilterEdge.getReferenceNodes()` is too broad for this check. For filter
edges, `HyperGraph.addFilter()` initializes the edge with
`childEdgeNodes.second`, so `getReferenceNodes()` becomes the entire child
subtree, not the nodes actually referenced by the predicate. A query like
`SELECT ... FROM t1 LEFT JOIN t2 ON t1.id = t2.id WHERE t1.id > 1` produces a
filter above the join whose `referenceNodes` still include `t2`; this branch
then treats eliminating `t2` as unsafe even though the filter only depends on
preserved-side columns. Please key this check off the filter's actual input
slots (or an equivalent node map) instead of `getReferenceNodes()`.
--
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]