[SPARK-58458][SQL][TESTS] Add coverage for the record split when multiLine is disabled - #57671
Open
Joorgem wants to merge 1 commit into
Open
[SPARK-58458][SQL][TESTS] Add coverage for the record split when multiLine is disabled#57671Joorgem wants to merge 1 commit into
Joorgem wants to merge 1 commit into
Conversation
…iLine is disabled
uros-b
reviewed
Jul 31, 2026
Member
There was a problem hiding this comment.
The test covers PERMISSIVE and DROPMALFORMED but omits FAILFAST. Please expand test coverage accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Adds a test to
CSVSuitepinning what the CSV reader does with a line break inside aquoted value when
multiLineis left at its default offalse: the record is cut atthe break into a NULL-tailed head plus a fragment, and the row count rises by one.
The test also pins the three consequences that follow from it — the
multiLine=truecontrast,
DROPMALFORMEDdiscarding both halves, and the raw text captured whencolumnNameOfCorruptRecordis declared.Why are the changes needed?
The behaviour is not covered today.
CSVSuitecontains exactly one input literal witha newline inside quotes, in the
lineSep with 2 chars when multiLine set to ...test,and it is confined to the
multiLine = truebranch:The
multiLine = falsebranch deliberately drops the quoted break, so the defaultpath is never exercised with the input that distinguishes it.
UnivocityParserSuitedoes not cover it either.
That leaves an untested behaviour that users do meet: a line break inside a quoted
value is valid CSV (RFC 4180 §2.6) and appears in published datasets, so reading such
a file with default options is an ordinary thing to do. The split is a consequence of
the non-multiLine read path being line-oriented by design —
HadoopFileLinesReadersplits the input on the line separator before the tokenizer sees it, and
UnivocityParser.parseLinethen receives one physical line at a time — which is whatmakes the file splittable. This PR does not propose changing that; it pins what the
current design produces, so a future change to that path cannot alter it silently.
DROPMALFORMEDlosing the whole source record rather than the damaged half is thepart most worth having locked down, since it is the opposite of what the mode's name
suggests for one bad line.
Does this PR introduce any user-facing change?
No. Test-only.
How was this patch tested?
This PR is the test. It was run in CI against this base before the PR was opened:
Build modules: sql - slow tests,sql - extended testsandsql - other testsallpassed, so the test holds in
CSVv1Suite,CSVv2SuiteandCSVLegacyTimeParserSuitealike.
The expected rows were derived before the Scala was written, from
pyspark3.5.9 withthe same three-record input and the same explicit three-column schema. 3.5.9 is two
majors behind this base, so those values were treated as a hypothesis to be confirmed
by that CI run rather than as evidence in themselves:
multiLine=false)("1","ACME LTDA","SP"),("2","EMPRESA COM",null),("QUEBRA DE LINHA\"","RJ",null),("3","OUTRA EMPRESA","MG")multiLine=truemode=DROPMALFORMEDcolumnNameOfCorruptRecorddeclared2,"EMPRESA COMandQUEBRA DE LINHA",RJReproduction script:
docs/evidence/c5_expected_rows.pyin the authoring repo (notpart of this patch).
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)
Related
This is the third of three separate concerns in the same area, filed in order:
multiLine=falsedoes to a line break inside a quoted value (open, reviewed, revision applied).
PERMISSIVE"drops corrupt records" sentence in the CSV and JSON docs.
Flagging the overlap explicitly since all three touch CSV: this one adds a test and
changes no docs and no
maincode.