apache / apache/arrow-java

Avro adapter: AvroNullableConsumer should use readIndex

Open
#834 0 comments 0 reactions 0 assignees View on GitHub
Type: bug
Dominant language
Java
Stars
94
Forks
152
Avg merge
3d 16h
Merged PRs (30d)
11

Description

### 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 `ValidatingDecoder`s and any Decoders based on that have different logic.

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.