Avro adapter: AvroNullableConsumer should use readIndex

Open
#834 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start in AvroNullableConsumer.consume, at the readInt call identified in the stack trace, and compare it with Avro's decoder API and ValidatingDecoder behavior. Done means nullable fields can be consumed with a ValidatingDecoder without the union-versus-int exception.

Written by the indexing model from the issue text.

Description

Type: bug
Describe the bug, including details regarding any error messages, version, and platform.

When using Avro's ValidatingDecoder, any schema with a nullable field fails with the following exception:

Exception in thread "main" org.apache.avro.AvroTypeException: Attempt to process a int when a union was expected.
	at org.apache.avro.io.parsing.Parser.advance(Parser.java:91)
	at org.apache.avro.io.ValidatingDecoder.readInt(ValidatingDecoder.java:81)
	at org.apache.arrow.adapter.avro.consumers.AvroNullableConsumer.consume(AvroNullableConsumer.java:44)

Reason: AvroNullableConsumer uses readInt to read the index, but it should use readIndex instead. It's irrelevant in case of a BinaryDecoder, for example (readIndex is the same as readInt), but ValidatingDecoders and any Decoders based on that have different logic.

Dominant language
Java
Stars
95
Forks
154
Avg merge
2d 10h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/arrow-java

All issues in apache/arrow-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.