jubins commented on code in PR #56581:
URL: https://github.com/apache/spark/pull/56581#discussion_r3438641976
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala:
##########
@@ -3588,6 +3588,72 @@ abstract class CSVSuite
matchPVals = true)
}
+ test("SPARK-57515: non-multiLine CSV read with header exceeding maxColumns
surfaces " +
+ "MALFORMED_CSV_RECORD") {
+ // CSVHeaderChecker called tokenizer.parseLine(header) directly without
the AIOOBE guard
+ // that UnivocityParser.parseLine wraps. A header line wider than
maxColumns must surface
+ // as MALFORMED_CSV_RECORD, not a raw ArrayIndexOutOfBoundsException.
+ withTempPath { path =>
+ Files.write(path.toPath,
"a,b,c\n1,2,3\n".getBytes(StandardCharsets.UTF_8))
+ val e = intercept[SparkRuntimeException] {
+ spark.read
+ .option("header", "true")
+ .option("maxColumns", "2")
+ .csv(path.getAbsolutePath)
+ .collect()
+ }
+ checkError(
+ exception = e,
+ condition = "MALFORMED_CSV_RECORD",
+ sqlState = Some("KD000"),
+ parameters = Map("badRecord" -> ".*"),
+ matchPVals = true)
Review Comment:
good catch, changed to `parameters = Map("badRecord" -> "a,b,c")` and
`matchPVals = false`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]