stevomitric commented on code in PR #56355:
URL: https://github.com/apache/spark/pull/56355#discussion_r3369245478
##########
sql/api/src/main/scala/org/apache/spark/sql/types/ops/TimestampNanosTypeApiOps.scala:
##########
@@ -99,6 +112,19 @@ class TimestampNTZNanosTypeApiOps(val t:
TimestampNTZNanosType) extends Timestam
class TimestampLTZNanosTypeApiOps(val t: TimestampLTZNanosType) extends
TimestampNanosTypeApiOps {
override def dataType: TimestampLTZNanosType = t
override protected def sqlTypeName: String = "TIMESTAMP_LTZ"
+ override protected def precision: Int = t.precision
+
+ // Zone-less callers (EXPLAIN, SQL-literal) have no session zone to render
LTZ in, so they still
+ // raise rather than guessing a default.
+ override def format(v: Any): String =
+ throw DataTypeErrors.cannotConvertNanosTimestampToStringError(dataType)
+
+ // LTZ rendering depends on the session time zone. The fraction formatter
has its own internal
+ // cache, so build it per call rather than caching it here.
+ override def format(v: Any, zoneId: ZoneId): String = {
+ val formatter = TimestampFormatter.getFractionFormatter(zoneId)
Review Comment:
This builds a fresh formatter per row, while NTZ caches its own. The zoneId
is constant across a cast - could we cache it here the same way NTZ does rather
than new-ing one each call?
--
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]