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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyConditionalFunction.java:
##########
@@ -97,10 +113,16 @@ coalesce, new NullLiteral(coalesce.getDataType()), 
ctx.rewriteContext
     private static Expression rewriteNvl(ExpressionMatchingContext<Nvl> ctx) {
         Nvl nvl = ctx.expr;
         if (nvl.child(0) instanceof NullLiteral) {
-            return TypeCoercionUtils.ensureSameResultType(nvl, nvl.child(1), 
ctx.rewriteContext);
+            return keepConditionalNullability(

Review Comment:
   This fixes the `SimplifyConditionalFunction` path, but `ifnull/nvl` can 
still lose non-nullability through `FoldConstantRuleOnFE.visitNvl()`. That 
method still rewrites `nvl(nonNullableExpr, nullLiteral)` / `nvl(nullLiteral, 
nonNullableExpr)` via `TypeCoercionUtils.ensureSameResultType(...)` and, for 
cases like `datetime(0) -> datetime(6)`, it returns a nullable `Cast`. Since FE 
constant folding is invoked directly in other planner flows 
(`FoldConstantRuleOnFE.evaluate(...)`, `InsertIntoValuesAnalyzer`, etc.), the 
regression is still reachable even after this change. Please apply the same 
nullability preservation there and add a fold-constant test for that path.



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