diff options
author | Yin Huai <yhuai@databricks.com> | 2015-02-12 18:08:01 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2015-02-12 18:08:01 -0800 |
commit | 1d0596a16e1d3add2631f5d8169aeec2876a1362 (patch) | |
tree | d691a0e0e370a13f8cd35ec7925ebddb2e159ff5 /sql/hive/src/main | |
parent | c025a468826e9b9f62032e207daa9d42d9dba3ca (diff) | |
download | spark-1d0596a16e1d3add2631f5d8169aeec2876a1362.tar.gz spark-1d0596a16e1d3add2631f5d8169aeec2876a1362.tar.bz2 spark-1d0596a16e1d3add2631f5d8169aeec2876a1362.zip |
[SPARK-3299][SQL]Public API in SQLContext to list tables
https://issues.apache.org/jira/browse/SPARK-3299
Author: Yin Huai <yhuai@databricks.com>
Closes #4547 from yhuai/tables and squashes the following commits:
6c8f92e [Yin Huai] Add tableNames.
acbb281 [Yin Huai] Update Python test.
7793dcb [Yin Huai] Fix scala test.
572870d [Yin Huai] Address comments.
aba2e88 [Yin Huai] Format.
12c86df [Yin Huai] Add tables() to SQLContext to return a DataFrame containing existing tables.
Diffstat (limited to 'sql/hive/src/main')
-rw-r--r-- | sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala index c78369d12c..eb1ee54247 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala @@ -198,6 +198,11 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with } } + override def getTables(databaseName: Option[String]): Seq[(String, Boolean)] = { + val dbName = databaseName.getOrElse(hive.sessionState.getCurrentDatabase) + client.getAllTables(dbName).map(tableName => (tableName, false)) + } + /** * Create table with specified database, table name, table description and schema * @param databaseName Database Name |