alekjarmov commented on code in PR #59671:
URL: https://github.com/apache/spark/pull/59671#discussion_r4376762308


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalog.scala:
##########
@@ -151,11 +152,29 @@ class JDBCTableCatalog extends TableCatalog
     }
   }
 
-  override def loadTable(ident: Identifier): Table = {
+  // The per-read value decides the resolved schema, so it must reach 
loadTable.
+  override def tableStateOptionKeys(): util.Set[String] =
+    util.Set.of(JDBCOptions.JDBC_ZONELESS_TIMESTAMP_AS_NTZ)
+
+  override def loadTable(
+      ident: Identifier,
+      context: TableContext,
+      stateOptions: CaseInsensitiveStringMap): Table = {
+    if (context.timeTravel().isPresent || stateOptions.isEmpty) {
+      super.loadTable(ident, context, stateOptions)
+    } else {
+      loadTableWithStateOptions(ident, 
stateOptions.asCaseSensitiveMap().asScala)

Review Comment:
     When state options are set, this branch goes straight to 
`loadTableWithStateOptions` and skips the default dispatch. That drops 
`context.writePrivileges()`, which the `TableCatalog` javadoc says an override 
must authorize. It also means subclass overrides of `loadTable(ident)` / 
`loadTable(ident, writePrivileges)` don't run, e.g. for `INSERT INTO t WITH 
('zonelessTimestampAsNTZ' = 'false') ...`.
   
    The new `CountingJDBCTableCatalog` test only covers the empty-state-options 
branch. Could you extend it with a `WITH ('zonelessTimestampAsNTZ' = 'true')` 
read and write? Have the catalog also override `loadTable(ident, 
writePrivileges)` and  assert it sees `INSERT`. H2 ignores the value, but the 
option still takes this  branch.



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