aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/sql/catalog.py
diff options
context:
space:
mode:
authorSean Zhong <seanzhong@databricks.com>2016-05-12 15:51:53 +0800
committerCheng Lian <lian@databricks.com>2016-05-12 15:51:53 +0800
commit33c6eb5218ce3c31cc9f632a67fd2c7057569683 (patch)
treeb8c84c24107bf1ece596450ef3a3eec26df1f21d /python/pyspark/sql/catalog.py
parent5207a005cc86618907b8f467abc03eacef485ecd (diff)
downloadspark-33c6eb5218ce3c31cc9f632a67fd2c7057569683.tar.gz
spark-33c6eb5218ce3c31cc9f632a67fd2c7057569683.tar.bz2
spark-33c6eb5218ce3c31cc9f632a67fd2c7057569683.zip
[SPARK-15171][SQL] Deprecate registerTempTable and add dataset.createTempView
## What changes were proposed in this pull request? Deprecates registerTempTable and add dataset.createTempView, dataset.createOrReplaceTempView. ## How was this patch tested? Unit tests. Author: Sean Zhong <seanzhong@databricks.com> Closes #12945 from clockfly/spark-15171.
Diffstat (limited to 'python/pyspark/sql/catalog.py')
-rw-r--r--python/pyspark/sql/catalog.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/python/pyspark/sql/catalog.py b/python/pyspark/sql/catalog.py
index 9cfdd0a99f..812dbba59e 100644
--- a/python/pyspark/sql/catalog.py
+++ b/python/pyspark/sql/catalog.py
@@ -166,34 +166,20 @@ class Catalog(object):
return DataFrame(df, self._sparkSession._wrapped)
@since(2.0)
- def dropTempTable(self, tableName):
- """Drops the temporary table with the given table name in the catalog.
- If the table has been cached before, then it will also be uncached.
+ def dropTempView(self, viewName):
+ """Drops the temporary view with the given view name in the catalog.
+ If the view has been cached before, then it will also be uncached.
- >>> spark.createDataFrame([(1, 1)]).registerTempTable("my_table")
+ >>> spark.createDataFrame([(1, 1)]).createTempView("my_table")
>>> spark.table("my_table").collect()
[Row(_1=1, _2=1)]
- >>> spark.catalog.dropTempTable("my_table")
+ >>> spark.catalog.dropTempView("my_table")
>>> spark.table("my_table") # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
AnalysisException: ...
"""
- self._jcatalog.dropTempTable(tableName)
-
- @since(2.0)
- def registerTable(self, df, tableName):
- """Registers the given :class:`DataFrame` as a temporary table in the catalog.
-
- >>> df = spark.createDataFrame([(2, 1), (3, 1)])
- >>> spark.catalog.registerTable(df, "my_cool_table")
- >>> spark.table("my_cool_table").collect()
- [Row(_1=2, _2=1), Row(_1=3, _2=1)]
- """
- if isinstance(df, DataFrame):
- self._jsparkSession.registerTable(df._jdf, tableName)
- else:
- raise ValueError("Can only register DataFrame as table")
+ self._jcatalog.dropTempView(viewName)
@ignore_unicode_prefix
@since(2.0)