amaliujia commented on code in PR #37241:
URL: https://github.com/apache/spark/pull/37241#discussion_r925974243


##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -120,7 +120,13 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
       val plan = ShowTables(UnresolvedNamespace(ident), None)
       val ret = sparkSession.sessionState.executePlan(plan).toRdd.collect()
       val tables = ret
-        .map(row => ident ++ Seq(row.getString(1)))
+        .map(row =>
+          // for views, their namespace are empty
+          if (row.getString(0).isEmpty) {
+            Seq(row.getString(1))
+          } else {
+            ident ++ Seq(row.getString(1))
+          })

Review Comment:
   [SPARK-39236](https://issues.apache.org/jira/browse/SPARK-39236) updated 
`listTables(dbName)`. This PR does not cause regression on that JIRA. 
   
   This is more like a side effect of 
[SPARK-39506](https://issues.apache.org/jira/browse/SPARK-39506). Because in 
[SPARK-39506](https://issues.apache.org/jira/browse/SPARK-39506) we support 
`setCurrentCatalog` and get `currentCatalog`, now for `listTables` it has a 
choice of which catalog to search for tables. In the past it always go to the 
only catalog which is `spark_catalog`, but now that catalog can be changed.
   
   `listDatabases()` was already updated to respect the current catalog.



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