ayushbilala commented on code in PR #54824:
URL: https://github.com/apache/spark/pull/54824#discussion_r3208030348
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala:
##########
@@ -970,6 +982,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"
Review Comment:
Fixed - Try/catch block that returned "UNKNOWN" on failure has been removed.
getTempViewOrPermanentTableMetadata now propagates exceptions directly,
consistent with the text path.
--
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]