github-actions[bot] commented on code in PR #61176:
URL: https://github.com/apache/doris/pull/61176#discussion_r3084527656
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/HyperGraphComparator.java:
##########
@@ -254,21 +254,28 @@ 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)) {
+ boolean hasNonInferredFilterEdgeOnCurrentEliminatedNode =
+
LongBitmap.getCardinality(shouldEliminateNodesOnCurrentEdge) > 0
+ && viewHyperGraph.getFilterEdges().stream()
+ .filter(e -> e.getExpressions().stream().anyMatch(expr
-> !ExpressionUtils.isInferred(expr)))
+ .anyMatch(e -> LongBitmap.isOverlap(
+ e.getReferenceNodes(),
shouldEliminateNodesOnCurrentEdge));
+ // For inner join + FK elimination, reject if the node
eliminated by the current edge
+ // still participates in any non-inferred filter edge. Such
filters would be skipped
+ // later once the eliminated node overlaps
shouldEliminateViewNodesMap.
Review Comment:
The removed `hasFilterEdgeAbove` check was guarding more than the inner-join
PK/FK case. `isLogicCompatible()` still discards unmatched view filter edges
that overlap `shouldEliminateViewNodesMap`, so narrowing the guard to
`joinEdge.getJoinType().isInnerJoin()` makes some LEFT JOIN rewrites unsound. A
concrete counterexample is an MV like `SELECT t1.id FROM t1 LEFT JOIN t2 ON
t1.id = t2.id WHERE t2.id IS NULL`; after this change the right side can be
eliminated and the residual filter disappears, which makes the MV look
equivalent to `SELECT t1.id FROM t1` when it is not. Please keep a safety check
for residual filter edges on eliminated LOJ nodes too, and add a negative test
for that shape.
##########
fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java:
##########
@@ -1200,38 +1203,28 @@ public static void loadJournal(Env env, Long logId,
JournalEntity journal) {
}
case OperationType.OP_ADD_CONSTRAINT: {
final AlterConstraintLog log = (AlterConstraintLog)
journal.getData();
- try {
- TableNameInfo tni = log.getTableNameInfo();
- Constraint constraint = log.getConstraint();
- if (tni == null) {
- LOG.warn("Failed to replay add constraint {}: "
- + "table name could not be resolved",
- constraint.getName());
- break;
- }
- env.getConstraintManager().addConstraint(
- tni, constraint.getName(), constraint, true);
- } catch (Exception e) {
- LOG.warn("Failed to replay add constraint", e);
- }
+ TableNameInfo tni = log.getTableNameInfo();
+ Constraint constraint = log.getConstraint();
+ Preconditions.checkState(tni != null,
+ "Failed to replay add constraint %s: table name
could not be resolved",
Review Comment:
`AlterConstraintLog.gsonPostProcess()` deliberately keeps `tableNameInfo`
null when an old ID-based entry cannot be resolved anymore. Before this patch,
replay logged and skipped those entries; with `Preconditions.checkState(...)`
here, the same historical journal now aborts `loadJournal()` and can prevent FE
startup. Please keep the previous tolerant behavior for replay, then do the
MTMV invalidation only when `tni` is available.
--
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]