Repository: spark Updated Branches: refs/heads/branch-2.0 095ddb4c9 -> d9dd46edd
[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 <bm...@us.ibm.com> Closes #13695 from bomeng/SPARK-15978. (cherry picked from commit bbad4cb48df2ac3ed7edb4c02db79540bd4085d8) Signed-off-by: Andrew Or <and...@databricks.com> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/d9dd46ed Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/d9dd46ed Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/d9dd46ed Branch: refs/heads/branch-2.0 Commit: d9dd46edd3635ed79134a1521403c4478a34d3b3 Parents: 095ddb4 Author: bomeng <bm...@us.ibm.com> Authored: Thu Jun 16 14:18:02 2016 -0700 Committer: Andrew Or <and...@databricks.com> Committed: Thu Jun 16 14:18:12 2016 -0700 ---------------------------------------------------------------------- .../org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala | 2 +- .../org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/d9dd46ed/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala ---------------------------------------------------------------------- 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 14da30a..fb3e1b3 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 { http://git-wip-us.apache.org/repos/asf/spark/blob/d9dd46ed/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala ---------------------------------------------------------------------- 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 1ec1bb1..7ab10d1 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. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org