github-actions[bot] commented on code in PR #66613:
URL: https://github.com/apache/doris/pull/66613#discussion_r3782702252


##########
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/mv/MvExplorationSuiteTest.java:
##########
@@ -926,6 +926,53 @@ void 
testNullRejectCompensationForInnerJoinFullJoinRewriteOnRightSide() {
                 .anyMatch(expression -> isNotNullOnSlot(expression, 
"o_orderdate")));
     }
 
+    @Test
+    void testNullRejectCompensationWithCastJoinConditionFallsBack() {
+        
connectContext.getSessionVariable().setDisableNereidsRules("INFER_PREDICATES,PRUNE_EMPTY_PARTITION");
+        CascadesContext queryContext = createCascadesContext(
+                "select lineitem.l_orderkey, orders.o_orderkey, 
orders.o_orderdate from lineitem "
+                        + "inner join orders on cast(lineitem.l_orderkey as 
bigint) "
+                        + "= cast(orders.o_orderkey as bigint)",
+                connectContext
+        );
+        Plan queryPlan = PlanChecker.from(queryContext)
+                .analyze()
+                .rewrite()
+                .applyExploration(RuleSet.BUSHY_TREE_JOIN_REORDER)
+                .getAllPlan().get(0).child(0);
+
+        CascadesContext viewContext = createCascadesContext(
+                "select lineitem.l_orderkey, orders.o_orderkey, 
orders.o_orderdate from lineitem "
+                        + "left outer join orders on cast(lineitem.l_orderkey 
as bigint) "
+                        + "= cast(orders.o_orderkey as bigint)",
+                connectContext
+        );
+        Plan viewPlan = PlanChecker.from(viewContext)
+                .analyze()
+                .rewrite()
+                .applyExploration(RuleSet.BUSHY_TREE_JOIN_REORDER)
+                .getAllPlan().get(0).child(0);
+
+        StructInfo queryStructInfo = StructInfo.of(queryPlan, queryPlan, 
queryContext);
+        StructInfo viewStructInfo = StructInfo.of(viewPlan, viewPlan, 
viewContext);
+        RelationMapping relationMapping = RelationMapping.generate(
+                queryStructInfo.getRelations(), viewStructInfo.getRelations(), 
8).get(0);
+        SlotMapping queryToView = SlotMapping.generate(relationMapping);
+        SlotMapping viewToQuery = queryToView.inverse();
+        LogicalCompatibilityContext compatibilityContext = 
LogicalCompatibilityContext.from(
+                relationMapping, viewToQuery, queryStructInfo, viewStructInfo);
+        ComparisonResult comparisonResult = StructInfo.isGraphLogicalEquals(
+                queryStructInfo, viewStructInfo, compatibilityContext);
+
+        Assertions.assertFalse(comparisonResult.isInvalid());
+        
Assertions.assertFalse(comparisonResult.getViewNoNullableSlot().isEmpty());
+
+        SplitPredicate compensatePredicates = Assertions.assertDoesNotThrow(

Review Comment:
   This regression test can pass on the base implementation because it returns 
before the code this PR changes. The reduced post-rewrite shape is:
   
   ```text
   Join(expr_cast_l = expr_cast_o)
     Project(..., CAST(l_orderkey) AS expr_cast_l)
     Project(..., CAST(o_orderkey) AS expr_cast_o)
   ```
   
   `getInnerJoinNullRejectSlots` therefore returns only the helper Slots. 
`getViewBasedNullRejectSlots` shuttles them back to `Cast` and drops them at 
lines 952-956, leaving `allNullRejectViewSlots` empty and returning at lines 
892-894 before `getShuttledRequireNoNullableViewSlots` runs. Both assertions 
here consequently pass with the old unconditional `Slot.class::cast`.
   
   Please add a query-only predicate on the preserved LEFT side, for example 
`where lineitem.l_shipdate = '2023-10-17'`. That keeps evidence nonempty and 
forces the base cast over the required RIGHT group, while this PR filters the 
Cast and still returns invalid as asserted.
   



-- 
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]

Reply via email to