aokolnychyi commented on code in PR #57799:
URL: https://github.com/apache/spark/pull/57799#discussion_r3770941837
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogV2Util.scala:
##########
@@ -481,6 +481,23 @@ private[sql] object CatalogV2Util {
case _: NoSuchDatabaseException => None
}
+ /**
+ * Extracts the options that may select table state from a complete option
map. These are the
+ * only options passed to `loadTable` and used to identify a pinned table
state.
+ */
+ def extractTableStateOptions(
+ catalog: CatalogPlugin,
+ options: CaseInsensitiveStringMap): CaseInsensitiveStringMap = {
+ val stateKeys = catalog.asTableCatalog.tableStateOptionKeys().asScala
+ .map(_.toLowerCase(Locale.ROOT))
+ .toSet
+ val projected = options.entrySet().asScala.collect {
+ case entry if stateKeys.contains(entry.getKey.toLowerCase(Locale.ROOT))
=>
+ entry.getKey -> entry.getValue
+ }.toMap
+ new CaseInsensitiveStringMap(projected.asJava)
+ }
+
def getTable(
Review Comment:
Can we add a short doc to this method to indicate that it is OK to pass all
options and state options will be extracted?
```
/**
* Loads a table from the catalog. Callers pass the complete read options,
but only the keys the
* catalog declares via `tableStateOptionKeys()` are forwarded to
`loadTable`, so the loaded table
* state stays independent of non-state options and of how many times the
table is referenced.
*/
```
--
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]