HyukjinKwon commented on a change in pull request #29088:
URL: https://github.com/apache/spark/pull/29088#discussion_r454135608



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
##########
@@ -2353,6 +2355,53 @@ abstract class CSVSuite extends QueryTest with 
SharedSparkSession with TestCsvDa
       assert(df.schema.last == StructField("col_mixed_types", StringType, 
true))
     }
   }
+
+  test("Some characters are garbled when opening csv files with Excel") {
+    // scalastyle:off nonascii
+    val chinese = "我爱中文"
+    val korean = "나는 한국인을 좋아한다"
+    val japanese = "私は日本人が好き"
+    // scalastyle:on nonascii
+    val english = "I love English"
+
+    val df = spark.sql(s"SELECT '$chinese' AS Chinese, '$korean' AS Korean," +
+      s"'$japanese' AS Japanese, '$english' AS English")
+
+    Seq(true, false).foreach { bom =>
+      withTempPath { p =>
+        val path = p.getAbsolutePath
+        df.write.option("bom", bom).csv(path)
+
+        val bytesReads = new mutable.ArrayBuffer[Long]()
+        val bytesReadListener = new SparkListener() {
+          override def onTaskEnd(taskEnd: SparkListenerTaskEnd) {
+            bytesReads += taskEnd.taskMetrics.inputMetrics.bytesRead
+          }
+        }
+        sparkContext.addSparkListener(bytesReadListener)

Review comment:
       @wangyum, I think you can have two tests. One is roundtrip, another one 
is check the size of bytes, for example, via using `binaryFile` source.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to