Gabriel39 commented on PR #66498:
URL: https://github.com/apache/doris/pull/66498#issuecomment-5301305262

   **[P1] Preserve forced short-circuit semantics across `IF` rewrites**
   
   `PaimonMergePlanner` builds `ShortCircuitIf` nodes so ordered `WHEN` clauses 
and inactive assignments remain lazy regardless of the 
`short_circuit_evaluation` session setting. However, both 
`ConditionRewrite.visitIf()` and `NestedCaseWhenCondToLiteral.visitIf()` 
rebuild a changed node with `new If(...)`. This drops the `AlwaysShortCircuit` 
marker before `ExpressionTranslator` can set `forceShortCircuitEvaluation`.
   
   A concrete trigger is:
   
   ```sql
   SET short_circuit_evaluation = false;
   
   MERGE INTO target t
   USING source s ON t.id = s.id
   WHEN MATCHED AND s.id <=> 1 THEN
       UPDATE SET value = s.value
   WHEN MATCHED AND assert_true(s.id < 0, 'later predicate evaluated') THEN
       DELETE;
   ```
   
   For a source row with `s.id = 1`, `NullSafeEqualToEqual` can rewrite `<=>` 
to `=` inside the generated outer `ShortCircuitIf`. 
`ConditionRewrite.visitIf()` then replaces that node with a regular `If`. The 
BE may eagerly evaluate the false branch, including the later 
`assert_true(...)` predicate, and fail even though the first `WHEN` clause has 
already matched. The same problem can affect an inactive assignment when a 
descendant expression is rewritten.
   
   Please preserve the original node semantics when rebuilding an `If`, for 
example by using `ifExpr.withChildren(...)`, or otherwise explicitly retain the 
forced-short-circuit marker. Please also add a regression test with 
`short_circuit_evaluation = false`, a condition that is actually changed by an 
expression rewrite (such as `<=>`), and an erroring later predicate or inactive 
assignment.
   


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