ayushbilala commented on code in PR #54824:
URL: https://github.com/apache/spark/pull/54824#discussion_r3208603940
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowTablesExec.scala:
##########
@@ -33,18 +36,32 @@ case class ShowTablesExec(
output: Seq[Attribute],
catalog: TableCatalog,
namespace: Seq[String],
- pattern: Option[String]) extends V2CommandExec with LeafExecNode {
+ pattern: Option[String],
+ asJson: Boolean = false) extends V2CommandExec with LeafExecNode {
override protected def run(): Seq[InternalRow] = {
- val rows = new ArrayBuffer[InternalRow]()
-
val tables = catalog.listTables(namespace.toArray)
- tables.map { table =>
- if (pattern.map(StringUtils.filterPattern(Seq(table.name()),
_).nonEmpty).getOrElse(true)) {
+ val filteredTables = tables.filter { table =>
+ pattern.map(StringUtils.filterPattern(Seq(table.name()),
_).nonEmpty).getOrElse(true)
+ }
+
+ if (asJson) {
+ val jsonTables = filteredTables.map { table =>
+ JObject(
+ "name" -> JString(table.name()),
Review Comment:
Fixed. JSON code is consolidated in ShowTablesJsonExec.toJsonEntry(). Both
schemas now have name as the first field: non-extended is {name, namespace,
isTemporary} and extended is {name, catalog, namespace, type, isTemporary}.
V1 path in ShowTablesCommand follows the same ordering.
--
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]