Repository navigation
fix(arrow-avro): decode records with no fields - #10771
Merged
Merged
Conversation
Jefffrey
reviewed
Aug 21, 2026
| Vec<Decoder>, | ||
| Vec<Option<AvroLiteral>>, | ||
| Option<Projector>, | ||
| usize, |
Contributor
There was a problem hiding this comment.
perhaps we should name the fields, now that we have many fields
Record {
fields: Fields,
decoders: Vec<Decoder>,
defaults: Vec<Option<AvroLiteral>>,
projector: Option<Projector>,
/// Useful when there are no fields (legal edge case)
row_count: usize
}
Contributor
Author
There was a problem hiding this comment.
thanks for the review! The fields are now named.
added 2 commits
September 1, 2026 22:11
An Avro record with no fields is legal, and encodes to zero bytes. The
reader accepts such a schema and decodes its (empty) bytes fine, but
fails at flush:
Invalid argument error: use StructArray::try_new_with_length or
StructArray::new_empty_fields to create a struct array with no
fields so that the length can be set correctly
`Decoder::Record` flushes through `StructArray::try_new`, which infers
its length from the first child array, but a zero-field record has no
child array.
`RecordDecoder::flush` (the top level) already handles this: it passes
its own `row_count` through `RecordBatchOptions::with_row_count`. This
change gives the nested case the same treatment. `Decoder::Record`
now carries a row count, incremented wherever a row is appended and
reset at `flush`.
sqd
force-pushed
the
avro-empty-record-decode
branch
from
September 1, 2026 21:14
b183083 to
64a6625
Compare
Jefffrey
approved these changes
Sep 2, 2026
Contributor
|
thanks @sqd |
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 18, 2026
An Avro record with no fields is legal, and encodes to zero bytes. The
reader accepts such a schema and decodes its (empty) bytes fine, but
fails at flush:
Invalid argument error: use StructArray::try_new_with_length or
StructArray::new_empty_fields to create a struct array with no
fields so that the length can be set correctly
`Decoder::Record` flushes through `StructArray::try_new`, which infers
its length from the first child array, but a zero-field record has no
child array.
`RecordDecoder::flush` (the top level) already handles this: it passes
its own `row_count` through `RecordBatchOptions::with_row_count`. This
change gives the nested case the same treatment. `Decoder::Record` now
carries a row count, incremented wherever a row is appended and reset at
`flush`.
# Which issue does this PR close?
- Closes apache#10770.
# Are these changes tested?
See included tests.
# Are there any user-facing changes?
No
---------
Co-authored-by: Han You <han.you@imc.com>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 21, 2026
An Avro record with no fields is legal, and encodes to zero bytes. The
reader accepts such a schema and decodes its (empty) bytes fine, but
fails at flush:
Invalid argument error: use StructArray::try_new_with_length or
StructArray::new_empty_fields to create a struct array with no
fields so that the length can be set correctly
`Decoder::Record` flushes through `StructArray::try_new`, which infers
its length from the first child array, but a zero-field record has no
child array.
`RecordDecoder::flush` (the top level) already handles this: it passes
its own `row_count` through `RecordBatchOptions::with_row_count`. This
change gives the nested case the same treatment. `Decoder::Record` now
carries a row count, incremented wherever a row is appended and reset at
`flush`.
# Which issue does this PR close?
- Closes apache#10770.
# Are these changes tested?
See included tests.
# Are there any user-facing changes?
No
---------
Co-authored-by: Han You <han.you@imc.com>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 25, 2026
An Avro record with no fields is legal, and encodes to zero bytes. The
reader accepts such a schema and decodes its (empty) bytes fine, but
fails at flush:
Invalid argument error: use StructArray::try_new_with_length or
StructArray::new_empty_fields to create a struct array with no
fields so that the length can be set correctly
`Decoder::Record` flushes through `StructArray::try_new`, which infers
its length from the first child array, but a zero-field record has no
child array.
`RecordDecoder::flush` (the top level) already handles this: it passes
its own `row_count` through `RecordBatchOptions::with_row_count`. This
change gives the nested case the same treatment. `Decoder::Record` now
carries a row count, incremented wherever a row is appended and reset at
`flush`.
# Which issue does this PR close?
- Closes apache#10770.
# Are these changes tested?
See included tests.
# Are there any user-facing changes?
No
---------
Co-authored-by: Han You <han.you@imc.com>
This was referenced Oct 10, 2026
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.
An Avro record with no fields is legal, and encodes to zero bytes. The reader accepts such a schema and decodes its (empty) bytes fine, but fails at flush:
Decoder::Recordflushes throughStructArray::try_new, which infers its length from the first child array, but a zero-field record has no child array.RecordDecoder::flush(the top level) already handles this: it passes its ownrow_countthroughRecordBatchOptions::with_row_count. This change gives the nested case the same treatment.Decoder::Recordnow carries a row count, incremented wherever a row is appended and reset atflush.Which issue does this PR close?
Are these changes tested?
See included tests.
Are there any user-facing changes?
No