Skip to content

fix: expose internal offsets in json/csv readers - #1342

Merged
zeroshade merged 1 commit into
apache:mainfrom
Willem-J-an:fix/offsets
Oct 13, 2026
Merged

zeroshade merged 1 commit into
apache:mainfrom
Willem-J-an:fix/offsets

Conversation

@Willem-J-an

Copy link
Copy Markdown
Contributor

Rationale for this change

When decoding non-typesafe formats like CSV and JSON it is possible decoding errors occur somewhere midstream. Without knowing the offset decoding fails at, it can become very hard to troubleshoot what/where in the data the problem is. For this I would like the Offset to be exposed to aid in troubleshooting when such problems occur.

What changes are included in this PR?

Expose internal InputOffset method directly in the CSV & JSON reader.

Are these changes tested?

No additional tests added; simple 1 to 1 exposure of internal InputOffset method.

Are there any user-facing changes?

Adds public InputOffset method on CSV & JSON readers.

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The forwarding methods are a useful additive API, approving; the observations below (doc comments on the offset semantics and focused tests) would be good follow-ups.

Smaller observations

  • minor — arrow/csv/reader.go:1110 — Please document both new exported methods, including byte units and the distinction between parser position and the location of an Arrow conversion error. For an Int64 column containing "1\nbad\n3\n4\n", I observed CSV offsets of 6, 8, and 10 with chunk sizes 1, 3, and -1, respectively, for the same conversion failure: nextn continues through the batch and nextall reads the complete input before conversion. That is consistent with exposing the parser offset, but it is not necessarily the failing row’s position. Also clarify that offsets are relative to the supplied stream, include consumed headers, and are not the underlying buffered reader’s read-ahead position.
  • minor — arrow/array/json_reader.go:232 — Please add focused tests for these public methods in both readers, covering the initial offset, successful reads, EOF, and errors, including CSV headers/chunking. Exercise JSON with both the default backend and arrow_json_stdlib: for "{\"v\":1}\n{\"v\":2}\n{\"v\":3}\n", I observed an offset of 24 after EOF with the default backend versus 23 with the standard-library backend; malformed-value offsets differed too. Document and test the intended decoder-position contract without implying a backend-independent exact error location. The PR currently adds no tests for the methods.
  • nit — CONTRIBUTING.md:22-31 / PR title — Consider feat(arrow): expose input offsets in JSON and CSV readers: this adds public API across two Arrow packages, and the contributing guide recommends a top-level scope for broader changes.

Targeted reader tests and a temporary offset/allocator probe passed locally with both JSON backends. The CI workflows on this PR are awaiting maintainer approval to run.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.

@zeroshade
zeroshade merged commit f2acefa into apache:main Oct 13, 2026
22 of 23 checks passed
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.

2 participants