ayushbilala commented on code in PR #54824:
URL: https://github.com/apache/spark/pull/54824#discussion_r3208530194


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala:
##########
@@ -938,6 +950,48 @@ case class ShowTablesCommand(
       Seq(Row(database, tableName, isTemp, s"$information\n"))
     }
   }
+
+  private def runAsJson(sparkSession: SparkSession): Seq[Row] = {
+    val catalog = sparkSession.sessionState.catalog
+    val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+    val tables =
+      tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+
+    val jsonTables = tables.map { tableIdent =>
+      val isTemp = catalog.isTempView(tableIdent)
+      val ns = tableIdent.database.toList
+
+      if (isExtended) {
+        val tableType = if (isTemp) {
+          "VIEW"
+        } else {
+          Try(catalog.getTempViewOrPermanentTableMetadata(tableIdent)) match {
+            case Success(meta) if meta.tableType == CatalogTableType.VIEW => 
"VIEW"
+            case Success(_) => "TABLE"
+            case Failure(_) => "UNKNOWN"
+          }
+        }
+
+        JObject(
+          "catalog" -> JString(
+            sparkSession.sessionState.catalogManager.currentCatalog.name()),

Review Comment:
   Fixed - now uses 
sparkSession.sessionState.catalogManager.v2SessionCatalog.name() as suggested. 
This correctly returns spark_catalog regardless of which catalog the user has 
set active via USE.



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