Skip to content
Snippets Groups Projects
Commit ce639129 authored by Cheng Lian's avatar Cheng Lian
Browse files

[HOTFIX] [SQL] Fixes DataFrameWriter.mode(String)

We forgot an assignment there.

/cc rxin

Author: Cheng Lian <lian@databricks.com>

Closes #6212 from liancheng/fix-df-writer and squashes the following commits:

711fbb0 [Cheng Lian] Adds a test case
3b72d78 [Cheng Lian] Fixes DataFrameWriter.mode(String)
parent 47e7ffe3
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ final class DataFrameWriter private[sql](df: DataFrame) { ...@@ -55,7 +55,7 @@ final class DataFrameWriter private[sql](df: DataFrame) {
* @since 1.4.0 * @since 1.4.0
*/ */
def mode(saveMode: String): DataFrameWriter = { def mode(saveMode: String): DataFrameWriter = {
saveMode.toLowerCase match { this.mode = saveMode.toLowerCase match {
case "overwrite" => SaveMode.Overwrite case "overwrite" => SaveMode.Overwrite
case "append" => SaveMode.Append case "append" => SaveMode.Append
case "ignore" => SaveMode.Ignore case "ignore" => SaveMode.Ignore
......
...@@ -75,6 +75,13 @@ class SaveLoadSuite extends DataSourceTest with BeforeAndAfterAll { ...@@ -75,6 +75,13 @@ class SaveLoadSuite extends DataSourceTest with BeforeAndAfterAll {
checkLoad() checkLoad()
} }
test("save with string mode and path, and load") {
conf.setConf(SQLConf.DEFAULT_DATA_SOURCE_NAME, "org.apache.spark.sql.json")
path.createNewFile()
df.write.mode("overwrite").save(path.toString)
checkLoad()
}
test("save with path and datasource, and load") { test("save with path and datasource, and load") {
conf.setConf(SQLConf.DEFAULT_DATA_SOURCE_NAME, "not a source name") conf.setConf(SQLConf.DEFAULT_DATA_SOURCE_NAME, "not a source name")
df.write.json(path.toString) df.write.json(path.toString)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment