Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/20004#discussion_r157545088
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
---
@@ -482,6 +482,37 @@ class CSVSuite extends QueryTest with SharedSQLContext
with SQLTestUtils {
}
}
+ test("save csv with quote escaping, using charToEscapeQuoteEscaping
option") {
+ withTempPath { path =>
+ val df1 = Seq(
+ """You are "beautiful"""",
+ """Yes, \in the inside\""", // ends with the escape character '\\'
+ """AA\\BB""", // 2 escape char
+ """AA""BB""", // 2 quote char
+ """AA\"BB\""", // 1 escape char and 1 quote char
+ """AA\""BB\""", // 1 escape char and 2 quote char
+ """AA\\"BB\""" // 2 escape char and 1 quote char
+ ).toDF()
+
+ // escapeQuotes is true by default
+ df1.coalesce(1).write
+ .format("csv")
+ .option("quote", "\"")
+ .option("escape", "\\")
+ .option("charToEscapeQuoteEscaping", "\\")
+ .save(path.getAbsolutePath)
+
+ val df2 = spark.read
+ .format("csv")
+ .option("quote", "\"")
+ .option("escape", "\\")
+ .option("charToEscapeQuoteEscaping", "\\")
+ .load(path.getAbsolutePath)
+
+ checkAnswer(df1, df2)
--- End diff --
I did not investigate the cause, but I saw this test case can pass without
this PR. Could you re-try it using the master branch?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]