yyanyy commented on code in PR #57865:
URL: https://github.com/apache/spark/pull/57865#discussion_r3786861131
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogV2Util.scala:
##########
@@ -519,6 +519,36 @@ private[sql] object CatalogV2Util {
catalog.asTableCatalog.loadTable(ident, context, stateOptions)
}
+ /**
+ * Loads a table for a write, forwarding the required privileges and only
the write options that
+ * the catalog declares may affect table state. The complete option map
remains on the write
+ * relation for write planning.
+ */
+ def getTableForWrite(
+ catalog: CatalogPlugin,
+ ident: Identifier,
+ writePrivileges: Set[TableWritePrivilege],
+ options: CaseInsensitiveStringMap): Table = {
+ rejectTimeTravelOptionsForWrite(catalog, ident, options)
+ val context = new TableContext(null, writePrivileges.asJava)
+ val stateOptions = extractTableStateOptions(catalog, options)
+ catalog.asTableCatalog.loadTable(ident, context, stateOptions)
+ }
+
+ private def rejectTimeTravelOptionsForWrite(
+ catalog: CatalogPlugin,
+ ident: Identifier,
+ options: CaseInsensitiveStringMap): Unit = {
+ val conf = SQLConf.get
+ val containsTimeTravelOption = Seq(
+ conf.getConf(SQLConf.TIME_TRAVEL_TIMESTAMP_KEY),
+
conf.getConf(SQLConf.TIME_TRAVEL_VERSION_KEY)).exists(options.containsKey)
+ if (containsTimeTravelOption) {
+ throw QueryCompilationErrors.timeTravelUnsupportedError(
Review Comment:
Addressed, thanks! Relation IDs now consistently use `toSQLId`, and
write-target time-travel options are detected before
`TimeTravelSpec.fromOptions`, so conflicting options report
`UNSUPPORTED_FEATURE.TIME_TRAVEL` instead of `INVALID_TIME_TRAVEL_SPEC`. The
actual rejection is deferred until identifier resolution because the catalog
and qualified identifier are not available earlier.
--
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]