MaxGekk commented on code in PR #56355:
URL: https://github.com/apache/spark/pull/56355#discussion_r3373505505
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala:
##########
@@ -1622,8 +1622,11 @@ abstract class CastSuiteBase extends SparkFunSuite with
ExpressionEvalHelper {
checkEvaluation(Cast(Literal(time), StringType), expectedStr)
}
+ // Cast to string now routes through the zone-aware Types Framework hook
(SPARK-57285), which
+ // evaluates the (zone-independent for TimeType) session zone, so resolve
a time zone like a
+ // real cast rather than leaving the TimeZoneAwareExpression unresolved.
checkConsistencyBetweenInterpretedAndCodegen(
- (child: Expression) => Cast(child, StringType), TimeType())
+ (child: Expression) => Cast(child, StringType, UTC_OPT), TimeType())
Review Comment:
Good catch, you're right. `TimeType` never forces the zone:
- `TypeApiOps.apply`'s `TimeType` branch builds `TimeTypeApiOps(tt)` without
referencing the by-name `zoneId`, so the thunk is never evaluated.
- `TimeType` codegen renders via `timeFormatter` (the framework hook only
covers the nanos timestamp types).
- `Cast.needsTimeZone(TimeType, StringType)` is `false`, so the cast is
resolved even with an unset zone.
So the `UTC_OPT` was unnecessary and the comment was misleading. I've
reverted to the zone-less `Cast(child, StringType)` and dropped the comment
(verified `CastWithAnsiOn/OffSuite` "cast time to string" still passes). Thanks!
--
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]