zml1206 commented on code in PR #12048:
URL: https://github.com/apache/gluten/pull/12048#discussion_r3200375900
##########
gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionConverter.scala:
##########
@@ -467,6 +467,22 @@ object ExpressionConverter extends SQLConfHelper with
Logging {
case s: ScalarSubquery =>
ScalarSubqueryTransformer(substraitExprName, s)
case c: Cast =>
+ // Gluten uses session-level timezone for cast. If the per-expression
timezone
+ // differs from session timezone and the cast involves timestamp type,
we must
+ // fall back to Spark native execution to ensure correctness.
+ c.timeZoneId.foreach {
+ tz =>
+ val sessionTz = SQLConf.get.sessionLocalTimeZone
+ if (tz != sessionTz) {
+ val involvesTimestamp = c.child.dataType == TimestampType ||
+ c.dataType == TimestampType
Review Comment:
Thanks. This only checks the top-level child/output type, so casts like
ArrayType(TimestampType) -> ArrayType(StringType), MapType(TimestampType, ...),
or structs containing timestamp still go to Velox when the Cast has a
per-expression timezone different from the session timezone. Spark Cast applies
the same zoneId recursively to array/map/struct elements, so these cases can
still return the session-timezone result instead of the expression-timezone
result.
--
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]