Skip to content

Commit 2546812

Browse files
committed
[SPARK-34710][SQL] Add isView for SHOW TABLES to distinguish view and tables
1 parent 5090900 commit 2546812

File tree

2 files changed

+0
-320
lines changed

2 files changed

+0
-320
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -813,37 +813,6 @@ case class DescribeColumnCommand(
813813
}
814814
}
815815

816-
/**
817-
* A command for users to get tables in the given database.
818-
* If a databaseName is not given, the current database will be used.
819-
* The syntax of using this command in SQL is:
820-
* {{{
821-
* SHOW TABLES [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
822-
* }}}
823-
*/
824-
case class ShowTblsCommand(
825-
databaseName: Option[String], tableIdentifierPattern: Option[String],
826-
override val output: Seq[Attribute]) extends RunnableCommand {
827-
override def run(sparkSession: SparkSession): Seq[Row] = {
828-
// Since we need to return a Seq of rows, we will call getTables directly
829-
// instead of calling tables in sparkSession.
830-
val catalog = sparkSession.sessionState.catalog
831-
val db = databaseName.getOrElse(catalog.getCurrentDatabase)
832-
// Show the information of tables.
833-
val tables =
834-
tableIdentifierPattern.map(catalog.listTables(db, _)).getOrElse(catalog.listTables(db))
835-
tables.map { tableIdent =>
836-
val database = tableIdent.database.getOrElse("")
837-
val tableName = tableIdent.table
838-
val isTemp = catalog.isTempView(tableIdent)
839-
val catalogTable = catalog.getTempViewOrPermanentTableMetadata(tableIdent)
840-
val isView = catalogTable.tableType == CatalogTableType.VIEW
841-
Row(database, tableName, isTemp, isView)
842-
}
843-
844-
}
845-
}
846-
847816
/**
848817
* A command for users to get tables in the given database.
849818
* If a databaseName is not given, the current database will be used.

sql/core/src/test/resources/sql-tests/results/show-tables-legacy.sql.out

Lines changed: 0 additions & 289 deletions
This file was deleted.

0 commit comments

Comments
 (0)