yadavay-amzn commented on code in PR #56627:
URL: https://github.com/apache/spark/pull/56627#discussion_r3605337302


##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetSchemasOperation.scala:
##########
@@ -71,15 +72,51 @@ private[hive] class SparkGetSchemasOperation(
 
     try {
       val schemaPattern = convertSchemaPattern(schemaName)
-      catalog.listDatabases(schemaPattern).foreach { dbName =>
-        rowSet.addRow(Array[AnyRef](dbName, DEFAULT_HIVE_CATALOG))
-      }
-
-      val globalTempViewDb = catalog.globalTempDatabase
-      val databasePattern = 
Pattern.compile(CLIServiceUtils.patternToRegex(schemaName))
-      if (schemaName == null || schemaName.isEmpty ||
-          databasePattern.matcher(globalTempViewDb).matches()) {
-        rowSet.addRow(Array[AnyRef](globalTempViewDb, DEFAULT_HIVE_CATALOG))
+      if (isCatalogMetadataEnabled) {
+        // The JDBC catalogName parameter is intentionally not used for 
filtering;
+        // resolution always uses the current catalog (SPARK-57518; per-catalog
+        // filtering deferred).
+        val resolvedCatalog = catalogManager.currentCatalog
+        val catalogNameValue = resolvedCatalog.name()
+        if (catalogNameValue == CatalogManager.SESSION_CATALOG_NAME) {
+          // For spark_catalog, use the V1 SessionCatalog directly 
(transparent delegation)

Review Comment:
   Thanks for raising this. With an overridden `spark_catalog` (e.g. Iceberg's 
`SparkSessionCatalog`), `catalogManager.currentCatalog.name()` is still 
`spark_catalog` (`SESSION_CATALOG_NAME`), so this branch is taken and it lists 
via the V1 `SessionCatalog` rather than the override's `listNamespaces()`. I 
think that's the intended behavior here: Iceberg's `SparkSessionCatalog` 
delegates its namespace listing to the built-in session catalog 
(`listNamespaces()` just calls `getSessionCatalog().listNamespaces()`), so the 
databases it exposes are the same ones the V1 catalog returns. Where it could 
differ is a custom `spark_catalog` override that lists its own namespaces 
instead of delegating. Do you think we should handle this in a follow-up change?
   



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