aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorbomeng <bmeng@us.ibm.com>2016-06-16 14:18:02 -0700
committerAndrew Or <andrew@databricks.com>2016-06-16 14:18:02 -0700
commitbbad4cb48df2ac3ed7edb4c02db79540bd4085d8 (patch)
treebafb6c6918d1b4b029dccf0f52127c867c7f6526 /sql
parent457126e420e66228cc68def4bc3d87e7a282069a (diff)
downloadspark-bbad4cb48df2ac3ed7edb4c02db79540bd4085d8.tar.gz
spark-bbad4cb48df2ac3ed7edb4c02db79540bd4085d8.tar.bz2
spark-bbad4cb48df2ac3ed7edb4c02db79540bd4085d8.zip
[SPARK-15978][SQL] improve 'show tables' command related codes
## What changes were proposed in this pull request? I've found some minor issues in "show tables" command: 1. In the `SessionCatalog.scala`, `listTables(db: String)` method will call `listTables(formatDatabaseName(db), "*")` to list all the tables for certain db, but in the method `listTables(db: String, pattern: String)`, this db name is formatted once more. So I think we should remove `formatDatabaseName()` in the caller. 2. I suggest to add sort to listTables(db: String) in InMemoryCatalog.scala, just like listDatabases(). ## How was this patch tested? The existing test cases should cover it. Author: bomeng <bmeng@us.ibm.com> Closes #13695 from bomeng/SPARK-15978.
Diffstat (limited to 'sql')
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala2
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala2
2 files changed, 2 insertions, 2 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
index 14da30a36f..fb3e1b3637 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
@@ -286,7 +286,7 @@ class InMemoryCatalog(hadoopConfig: Configuration = new Configuration) extends E
override def listTables(db: String): Seq[String] = synchronized {
requireDbExists(db)
- catalog(db).tables.keySet.toSeq
+ catalog(db).tables.keySet.toSeq.sorted
}
override def listTables(db: String, pattern: String): Seq[String] = synchronized {
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
index 1ec1bb1baf..7ab10d1c38 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
@@ -445,7 +445,7 @@ class SessionCatalog(
/**
* List all tables in the specified database, including temporary tables.
*/
- def listTables(db: String): Seq[TableIdentifier] = listTables(formatDatabaseName(db), "*")
+ def listTables(db: String): Seq[TableIdentifier] = listTables(db, "*")
/**
* List all matching tables in the specified database, including temporary tables.