This is an automated email from the ASF dual-hosted git repository.

changchen pushed a commit to branch feature/ansi-ci-baseline
in repository https://gitbox.apache.org/repos/asf/gluten.git

commit cd0ebef297416715cfa9f1fdca2e7ccacdeab2a8
Author: Chang chen <[email protected]>
AuthorDate: Thu Apr 2 02:25:15 2026 +0000

    [GLUTEN-10134][VL] Fix SPARK-38228: LEGACY store assignment cast should not 
throw under ANSI mode
    
    CastTransformer used withTryEvalMode() to decide isTryCast, which only
    returned true for TRY eval mode. LEGACY eval mode casts (e.g., from
    storeAssignmentPolicy=LEGACY) were sent as strict casts to Velox, causing
    VeloxUserError on invalid input even when LEGACY policy should return NULL.
    
    Change to !withAnsiEvalMode(): only ANSI eval mode casts use strict path;
    LEGACY and TRY both use try-cast (return NULL on failure). This is safe
    because in non-ANSI sessions, Velox's SparkCastCallToSpecialForm already
    computes isTryCast=true internally, so behavior is unchanged.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../org/apache/gluten/expression/UnaryExpressionTransformer.scala     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/UnaryExpressionTransformer.scala
 
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/UnaryExpressionTransformer.scala
index 52cd0115db..d8404cd84d 100644
--- 
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/UnaryExpressionTransformer.scala
+++ 
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/UnaryExpressionTransformer.scala
@@ -54,7 +54,7 @@ case class CastTransformer(substraitExprName: String, child: 
ExpressionTransform
         ExpressionBuilder.makeCast(
           typeNode,
           child.doTransform(context),
-          SparkShimLoader.getSparkShims.withTryEvalMode(original))
+          !SparkShimLoader.getSparkShims.withAnsiEvalMode(original))
     }
   }
 
@@ -67,7 +67,7 @@ case class CastTransformer(substraitExprName: String, child: 
ExpressionTransform
     val castNode = ExpressionBuilder.makeCast(
       stringTypeNode,
       child.doTransform(context),
-      SparkShimLoader.getSparkShims.withTryEvalMode(original))
+      !SparkShimLoader.getSparkShims.withAnsiEvalMode(original))
     val funcName =
       ConverterUtils.makeFuncName(checkFuncName, Seq(StringType, IntegerType))
     val functionId = context.registerFunction(funcName)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to