Repository navigation
fix(lib-storage): keep empty fields when splitting per-line records - #1521
Merged
Merged
Conversation
why: the per-line transportOneRecord used StringUtils.split, which drops empty and trailing-empty tokens, so sequence-file rows containing empty columns shifted every later column against the configured index/type mapping and were misread or silently collected as dirty, while the commons-csv path reads the same content with the empty fields intact. what: replace the split with an indexOf-based splitter that keeps every token, matching the commons-csv semantics of doReadFromStream. impact: hdfsreader sequence-file rows with empty fields now map to the correct columns and match fileType=text behavior; only the sequence-file per-line path is affected.
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.
Summary
The per-line
transportOneRecord(RecordSender, Configuration, TaskPluginCollector, String)overload (the hdfsreader sequence-file path, invoked once per record fromDFSUtil.sequenceFileStartRead) split record lines withStringUtils.split, which drops empty tokens and trailing empties.A Hive/sequence-file row with an empty column (e.g.
a,,b) was split to[a, b], shifting every subsequent column against the configured index/type mapping — values landed in the wrong typed column or the row was thrown away as dirty with anIndexOutOfBoundsException. The same content read through the commons-csv path (doReadFromStream,fileType=text) keeps the empty fields, so behavior was inconsistent by file type and data was silently corrupted on the seq path.What type of change is this?
Changes
StringUtils.split(line, fieldDelimiter)with a smallindexOf-based splitter that keeps every token, including empty and trailing-empty ones — the same semantics commons-csv produces on thedoReadFromStreampath.Motivation and Context
Reported against
lib/addax-storageby a module code review (cross-file contract tracer verified the divergence between the seq per-line path and the commons-csv path).How has this been tested?
mvn -DskipTests compile -pl :addax-storage(JDK 17) — clean."a,,b"→ 3 tokens,"a,b,"→ 3 tokens, no-delimiter line → 1 token.Checklist (required)