Skip to content

fix(arrow/csv): validate custom converter row counts - #1148

Merged
zeroshade merged 2 commits into
apache:mainfrom
fallintoplace:fix/csv-custom-converter-length
Aug 12, 2026
Merged

fix(arrow/csv): validate custom converter row counts#1148
zeroshade merged 2 commits into
apache:mainfrom
fallintoplace:fix/csv-custom-converter-length

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

What

The custom CSV writer converter is documented to return one string per array value, but the writer trusted the result. Short results silently produced empty cells and long results could panic while filling the record matrix. This returns arrow.ErrInvalid for either mismatch.

Test

  • go test ./arrow/csv -run TestCustomTypeConverterValidatesRowCount -count=1

@fallintoplace
fallintoplace marked this pull request as ready for review August 8, 2026 15:52

@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.

LGTM — custom converter results are now validated before CSV matrix indexing, returning arrow.ErrInvalid for both short and long results without emitting partial rows.

I ran the regression 100 times, the focused race tests 20 times, a later-column atomicity probe, and the full arrow/csv package with its fixture submodules; all passed on head 95551a6d6600. CI is green.

One nonblocking documentation correction is noted inline: WithCustomTypeConverter should describe its result as one string per row/value rather than per CSV column.


This review was drafted by an AI-assisted tool and confirmed by an Apache Arrow Go 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 Go handles maintainer review: CONTRIBUTING.md.

Comment thread arrow/csv/transformer.go
if w.customTypeConverter != nil {
result, handled := w.customTypeConverter(typ, col)
if handled {
if len(result) != col.Len() {

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.

This correctly validates against col.Len(), but the public WithCustomTypeConverter documentation in common.go currently says the returned slice must match “the number of columns in the output csv.” Since this callback handles one column at a time, that should say it must contain one string per row/value in col. Could we update that documentation alongside the new validation?

@zeroshade
zeroshade merged commit 805290e into apache:main Aug 12, 2026
20 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