uros-b commented on code in PR #56355:
URL: https://github.com/apache/spark/pull/56355#discussion_r3376373666
##########
sql/api/src/main/scala/org/apache/spark/sql/types/ops/TypeApiOps.scala:
##########
@@ -152,15 +155,24 @@ object TypeApiOps {
*
* @param dt
* the DataType to get operations for
+ * @param zoneId
+ * the session time zone for zone-aware rendering (TIMESTAMP_LTZ nanos).
CAST passes the
+ * cast's resolved zone; zone-less callers (EXPLAIN / SQL-literal / Row
JSON) accept the
Review Comment:
One issue with the "Does this PR introduce any user-facing change?" section
— the three zone-less callers don't hold up:
EXPLAIN / SQL-literal toSQLValue don't route through the framework.
Literal.sql/Literal.toString render nanos via value.toString (the
TimestampNanosVal(<micros>, <nanos>) debug string), and the framework
toSQLValue has no production caller. So neither raised before nor changes now.
Row.jsonValue looks broken rather than fixed. A public Row holds external
values (InstantNanosEncoder→Instant, LocalDateTimeNanosEncoder→LocalDateTime),
but Row.jsonValue calls ops.format(value), and the new format does
v.asInstanceOf[TimestampNanosVal]. So someRow.json on a nanos column would
throw ClassCastException (Instant/LocalDateTime → TimestampNanosVal).
Previously this raised the clean UNSUPPORTED_FEATURE.TIMESTAMP_NANOS_TO_STRING.
The external-value path should go through formatExternal (as HiveResult does),
not format.
This path also isn't covered: TimestampNanosRowSuite only exercises
InternalRow/UnsafeRow, never Row.jsonValue.
Could you confirm Row(...).json behavior on a nanos LTZ/NTZ column and add a
test? Either fix Row.jsonValue to use the external value, or drop
EXPLAIN/SQL-literal/Row.jsonValue from the user-facing-change description and
keep that scope to the (correct) CAST path.
@MaxGekk PTAL and investigate this a bit more ^^
--
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]