Yao-MR commented on code in PR #12048:
URL: https://github.com/apache/gluten/pull/12048#discussion_r3205831344
##########
gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionConverter.scala:
##########
@@ -467,6 +467,34 @@ 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.
+ // Note: Spark Cast applies zoneId recursively to array/map/struct
elements,
+ // so we must check nested types as well.
+ c.timeZoneId.foreach {
+ tz =>
+ val sessionTz = SQLConf.get.sessionLocalTimeZone
+ if (tz != sessionTz) {
+ def containsTimestamp(dataType: DataType): Boolean = dataType
match {
+ case TimestampType => true
+ case a: ArrayType => containsTimestamp(a.elementType)
+ case m: MapType =>
+ containsTimestamp(m.keyType) ||
containsTimestamp(m.valueType)
+ case s: StructType => s.exists(f =>
containsTimestamp(f.dataType))
+ case udt: UserDefinedType[_] =>
+ containsTimestamp(udt.sqlType)
+ case _ => false
+ }
Review Comment:
sure, and extract the recursive timestamp-type check as a private helper
`involvesTimestampType`,no functional change; pure readability refactor.
--
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]