Skip to content

fix(lib-storage): keep empty fields when splitting per-line records - #1521

Merged
wgzhao merged 1 commit into
masterfrom
fix/sequencefile-empty-fields
Sep 3, 2026
Merged

wgzhao merged 1 commit into
masterfrom
fix/sequencefile-empty-fields

Conversation

@wgzhao

@wgzhao wgzhao commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

The per-line transportOneRecord(RecordSender, Configuration, TaskPluginCollector, String) overload (the hdfsreader sequence-file path, invoked once per record from DFSUtil.sequenceFileStartRead) split record lines with StringUtils.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 an IndexOutOfBoundsException. 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?

  • Bugfix

Changes

  • Replaced StringUtils.split(line, fieldDelimiter) with a small indexOf-based splitter that keeps every token, including empty and trailing-empty ones — the same semantics commons-csv produces on the doReadFromStream path.

Motivation and Context

Reported against lib/addax-storage by 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.
  • Manual trace: "a,,b" → 3 tokens, "a,b," → 3 tokens, no-delimiter line → 1 token.
  • No unit tests added; per project convention, verification happens in the build environment manually.

Checklist (required)

  • I have read the project's contributing guidelines and code of conduct.
  • My change includes appropriate tests (if applicable). — n/a, manual verification per project convention
  • I ran a local build and fixed any compilation issues.
  • I updated or added documentation if needed (README, docs/ or docs/en/). — n/a
  • I updated CHANGELOG.md when appropriate.
  • I have not added any secrets or credentials.
  • I have checked for sensitive or personal data in this PR.

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.
@wgzhao
wgzhao merged commit 3272319 into master Sep 3, 2026
2 checks passed
@wgzhao
wgzhao deleted the fix/sequencefile-empty-fields branch September 4, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant