ayushbilala commented on code in PR #54824:
URL: https://github.com/apache/spark/pull/54824#discussion_r3208561336
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowTablesExtendedExec.scala:
##########
@@ -73,6 +85,46 @@ case class ShowTablesExtendedExec(
rows.toSeq
}
+ private def runAsJson(): Seq[InternalRow] = {
+ val jsonRows = new ArrayBuffer[JObject]()
+
+ // fetch tables
+ val tables = catalog.listTables(namespace.toArray)
+ tables.foreach { tableIdent =>
+ if (StringUtils.filterPattern(Seq(tableIdent.name()), pattern).nonEmpty)
{
+ // V2 persistent tables are always TABLE
+ jsonRows += JObject(
+ "catalog" -> JString(catalog.name()),
+ "namespace" -> JArray(tableIdent.namespace().map(JString(_)).toList),
+ "name" -> JString(tableIdent.name()),
+ "type" -> JString("TABLE"),
+ "isTemporary" -> JBool(false)
+ )
+ }
+ }
+
+ // fetch temp views, includes: global temp view, local temp view
+ val sessionCatalog = session.sessionState.catalog
+ val db = namespace match {
+ case Seq(db) => Some(db)
+ case _ => None
+ }
+ val tempViews = sessionCatalog.listTempViews(db.getOrElse(""), pattern)
Review Comment:
Fixed. JSON path has been extracted to ShowTablesJsonExec. There is a guard
!CatalogV2Util.isSessionCatalog(catalog) to prevent the duplicate
listTempViews() fetch when catalog is V2SessionCatalog.
Remaining code in ShowTablesExtendedExec is the text-only path, which is
unchanged.
--
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]