1. [SPARK-25660][SQL] Fix for the backward slash as CSV fields delimiter (details)
Commit c7eadb5e6652468f9d5cd714c112ba1de187eea8 by gatorsmile
[SPARK-25660][SQL] Fix for the backward slash as CSV fields delimiter
## What changes were proposed in this pull request?
The PR addresses the exception raised on accessing chars out of
delimiter string. In particular, the backward slash `\` as the CSV
fields delimiter causes the following exception on reading `abc\1`:
```Scala String index out of range: 1
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.charAt(
``` because `str.charAt(1)` tries to access a char out of `str` in
## How was this patch tested?
Added tests for empty string and string containing the backward slash to
`CSVUtilsSuite`. Besides of that I added an end-to-end test to check how
the backward slash is handled in reading CSV string with it.
Closes #22654 from MaxGekk/csv-slash-delim.
Authored-by: Maxim Gekk <> Signed-off-by:
gatorsmile <>
The file was modifiedsql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVUtilsSuite.scala (diff)
The file was modifiedsql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala (diff)
The file was modifiedsql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVUtils.scala (diff)