cloud-fan commented on code in PR #57698:
URL: https://github.com/apache/spark/pull/57698#discussion_r3749754408


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala:
##########
@@ -233,7 +244,15 @@ object JdbcUtils extends Logging with SQLConfHelper {
           else TimeType.DEFAULT_PRECISION
         TimeType(timePrecision)
       } else getTimestampType(isTimestampNTZ)
-    case java.sql.Types.TIMESTAMP => getTimestampType(isTimestampNTZ)
+    case java.sql.Types.TIMESTAMP =>
+      // When nanosecond timestamps are requested (and the preview feature is 
enabled), a driver
+      // TIMESTAMP that reports a sub-microsecond fractional-second scale 
(7-9) is mapped to the
+      // nanosecond-capable type. Otherwise the historical microsecond mapping 
is preserved.
+      if (preferTimestampNanos && conf.timestampNanosTypesEnabled &&

Review Comment:
   Check the scale bounds before reading `conf.timestampNanosTypesEnabled`. 
This method runs once per JDBC column, so the current order performs an active 
SQLConf lookup for every TIMESTAMP(0-6) whenever the option is enabled, even 
though those scales cannot select a nanos type. Reordering the conjunction 
preserves behavior and short-circuits that repeated work.



-- 
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]

Reply via email to