diff options
author | shijinkui <shijinkui666@163.com> | 2016-02-17 15:08:22 -0800 |
---|---|---|
committer | Josh Rosen <joshrosen@databricks.com> | 2016-02-17 15:08:22 -0800 |
commit | 97ee85daf68345cf5c3c11ae5bf288cc697bdf9e (patch) | |
tree | 11e037cda2efb49eb2beaa0159f469f812a36206 /examples/src | |
parent | 1eac3800087a804c4b58a4af8b65eeb0879b6528 (diff) | |
download | spark-97ee85daf68345cf5c3c11ae5bf288cc697bdf9e.tar.gz spark-97ee85daf68345cf5c3c11ae5bf288cc697bdf9e.tar.bz2 spark-97ee85daf68345cf5c3c11ae5bf288cc697bdf9e.zip |
[SPARK-12953][EXAMPLES] RDDRelation writer set overwrite mode
https://issues.apache.org/jira/browse/SPARK-12953
fix error when run RDDRelation.main():
"path file:/Users/sjk/pair.parquet already exists"
Set DataFrameWriter's mode to SaveMode.Overwrite
Author: shijinkui <shijinkui666@163.com>
Closes #10864 from shijinkui/set_mode.
Diffstat (limited to 'examples/src')
-rw-r--r-- | examples/src/main/scala/org/apache/spark/examples/sql/RDDRelation.scala | 7 |
1 files changed, 3 insertions, 4 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 2cc56f04e5..a2f0fcd0e4 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 @@ -19,8 +19,7 @@ package org.apache.spark.examples.sql import org.apache.spark.{SparkConf, SparkContext} -import org.apache.spark.sql.SQLContext -import org.apache.spark.sql.functions._ +import org.apache.spark.sql.{SaveMode, SQLContext} // One method for defining the schema of an RDD is to make a case class with the desired column // names and types. @@ -58,8 +57,8 @@ object RDDRelation { // Queries can also be written using a LINQ-like Scala DSL. df.where($"key" === 1).orderBy($"value".asc).select($"key").collect().foreach(println) - // Write out an RDD as a parquet file. - df.write.parquet("pair.parquet") + // Write out an RDD as a parquet file with overwrite mode. + df.write.mode(SaveMode.Overwrite).parquet("pair.parquet") // Read in parquet file. Parquet files are self-describing so the schmema is preserved. val parquetFile = sqlContext.read.parquet("pair.parquet") |