Skip to content

GH-832: [Avro] Use readString in AvroStringConsumer - #1520

Open
dragonknightk wants to merge 1 commit into
apache:mainfrom
dragonknightk:fix-avro-string-consumer-readstring-832
Open

dragonknightk wants to merge 1 commit into
apache:mainfrom
dragonknightk:fix-avro-string-consumer-readstring-832

Conversation

@dragonknightk

@dragonknightk dragonknightk commented Nov 24, 2026 •

Copy link
Copy Markdown

What's Changed

AvroStringConsumer read string fields with Decoder.readBytes. That works with BinaryDecoder, because the binary encoding for string and bytes is the same. ResolvingDecoder checks the reader schema and throws AvroTypeException: "Attempt to process a bytes when a string was expected." ValidatingDecoder throws the same error, and this change fixes both.

The consumer now calls Decoder.readString and copies the Utf8 bytes into the VarCharVector, reusing the Utf8 instance the same way the old code reused a ByteBuffer.

Closes #832.

AI Disclosure

Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission.

## What's Changed

AvroStringConsumer read string fields with Decoder.readBytes. That works with BinaryDecoder, because the binary encoding for string and bytes is the same. ResolvingDecoder checks the reader schema and throws AvroTypeException: "Attempt to process a bytes when a string was expected." ValidatingDecoder throws the same error, and this change fixes both.

The consumer now calls Decoder.readString and copies the Utf8 bytes into the VarCharVector, reusing the Utf8 instance the same way the old code reused a ByteBuffer.

The new test reads "v1", an empty string and a non-ASCII string through a ResolvingDecoder and checks the vector holds the same values; the empty string after a longer value and the multi-byte characters check that only the valid bytes of the reused Utf8 are copied.

Closes issue 832.

Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com>
@github-actions

This comment has been minimized.

@lidavidm lidavidm added the bug-fix PRs that fix a big. label Nov 24, 2026
@github-actions github-actions Bot added this to the 20.1.0 milestone Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avro adapter: AvroStringConsumer should use readString instead of readBytes

2 participants