linkedin / linkedin/avro-util

Schema names might not be Java valid identifiers

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

Nobody has claimed this yet.

Dominant language
Java
Stars
87
Forks
73
Avg merge
2h 50m
Merged PRs (30d)
1

Description

The `FastSerializerGenerator` calls `Schema.getName()` to create temporary variable names when iterating over some arrays and maps. If the element type is a union, then the name created by `Schema.UnionSchema.getName()` is not a valid Java identifier. The generated code causes compiler errors that look like this:
```
/tmp/generated16917366869434796488/com/linkedin/avro/fastserde/generated/serialization/AVRO_1_11/Record_GenericSerializer_1168413672.java:97: error: ']' expected
CharSequence union[null, string]0 = null;
```

This is only a problem starting with `org.apache.avro:avro:1.12.0`, which was released last month: https://github.com/apache/avro/commit/ed2dbd4d871e9ab1992c39e38d9d56f33ce55127#diff-22eb7312aa7f632f0f9b1c3f40de619f91a303ee39f43d3a62a338adf745d1efR1289 . (There are other test failures related to logical types that will need to be fixed for full Avro 1.12.0 compatibility, but this was the only issue causing compilation errors.)

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.

Research direction

Start in FastSerializerGenerator and trace how Schema.getName() is used for temporary variable names, then reproduce the failure with an element type that is a union under org.apache.avro:avro:1.12.0. The work is done when generated Java uses valid identifiers for these names and the generated serializer compiles without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.