HyukjinKwon commented on a change in pull request #25184: [SPARK-28431][SQL]
Set maximum error message length in CSV datasource's parsing and writing
URL: https://github.com/apache/spark/pull/25184#discussion_r305670440
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
##########
@@ -2085,4 +2087,28 @@ class CSVSuite extends QueryTest with SharedSQLContext
with SQLTestUtils with Te
}
}
}
+
+ test("SPARK-28431: prevent CSV datasource throw TextParsingException with
large size message") {
+ withTempDir { dir =>
Review comment:
I think it doesn't remove parent dir. Can we do
```diff
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
index f3ab1b812e4..abbca28434c 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
@@ -2089,13 +2089,12 @@ class CSVSuite extends QueryTest with
SharedSQLContext with SQLTestUtils with Te
}
test("SPARK-28431: prevent CSV datasource throw TextParsingException with
large size message") {
- withTempDir { dir =>
+ withTempPath { path =>
val maxCharsPerCol = 10000
val str = "a" * (maxCharsPerCol + 1)
- val csvFile = new File(dir, "data.csv")
Files.write(
- csvFile.toPath,
+ path.toPath,
Seq(str).asJava,
StandardOpenOption.CREATE, StandardOpenOption.WRITE
)
@@ -2103,7 +2102,7 @@ class CSVSuite extends QueryTest with SharedSQLContext
with SQLTestUtils with Te
val errMsg = intercept[TextParsingException] {
spark.read
.option("maxCharsPerColumn", maxCharsPerCol)
- .csv(csvFile.getAbsolutePath)
+ .csv(path.getAbsolutePath)
.count()
}.getMessage
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]