diff options
author | Sean Zhong <seanzhong@databricks.com> | 2016-05-12 15:51:53 +0800 |
---|---|---|
committer | Cheng Lian <lian@databricks.com> | 2016-05-12 15:51:53 +0800 |
commit | 33c6eb5218ce3c31cc9f632a67fd2c7057569683 (patch) | |
tree | b8c84c24107bf1ece596450ef3a3eec26df1f21d /examples/src/main/scala | |
parent | 5207a005cc86618907b8f467abc03eacef485ecd (diff) | |
download | spark-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 'examples/src/main/scala')
-rw-r--r-- | examples/src/main/scala/org/apache/spark/examples/sql/RDDRelation.scala | 4 | ||||
-rw-r--r-- | examples/src/main/scala/org/apache/spark/examples/streaming/SqlNetworkWordCount.scala | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/examples/src/main/scala/org/apache/spark/examples/sql/RDDRelation.scala b/examples/src/main/scala/org/apache/spark/examples/sql/RDDRelation.scala index 94c378ae4b..d1bda0ff84 100644 --- a/examples/src/main/scala/org/apache/spark/examples/sql/RDDRelation.scala +++ b/examples/src/main/scala/org/apache/spark/examples/sql/RDDRelation.scala @@ -37,7 +37,7 @@ object RDDRelation { val df = spark.createDataFrame((1 to 100).map(i => Record(i, s"val_$i"))) // Any RDD containing case classes can be registered as a table. The schema of the table is // automatically inferred using scala reflection. - df.registerTempTable("records") + df.createOrReplaceTempView("records") // Once tables have been registered, you can run SQL queries over them. println("Result of SELECT *:") @@ -67,7 +67,7 @@ object RDDRelation { parquetFile.where($"key" === 1).select($"value".as("a")).collect().foreach(println) // These files can also be registered as tables. - parquetFile.registerTempTable("parquetFile") + parquetFile.createOrReplaceTempView("parquetFile") spark.sql("SELECT * FROM parquetFile").collect().foreach(println) spark.stop() diff --git a/examples/src/main/scala/org/apache/spark/examples/streaming/SqlNetworkWordCount.scala b/examples/src/main/scala/org/apache/spark/examples/streaming/SqlNetworkWordCount.scala index 9aba4a05a8..688c5b23c2 100644 --- a/examples/src/main/scala/org/apache/spark/examples/streaming/SqlNetworkWordCount.scala +++ b/examples/src/main/scala/org/apache/spark/examples/streaming/SqlNetworkWordCount.scala @@ -67,7 +67,7 @@ object SqlNetworkWordCount { val wordsDataFrame = rdd.map(w => Record(w)).toDF() // Register as table - wordsDataFrame.registerTempTable("words") + wordsDataFrame.createOrReplaceTempView("words") // Do word count on table using SQL and print it val wordCountsDataFrame = |