apache / apache/parquet-java

Enums are incorrectly handled by parquet-avro when using GenericRecords

Open
#1,952 0 comments 0 reactions 0 assignees View on GitHub
Component: Parquet Priority: Minor Type: bug
Dominant language
Java
Stars
3.1k
Forks
1.6k
Avg merge
3d 12h
Merged PRs (30d)
33

Description

It appears that enums are handled incorrectly when reading parquet as generic records.

Looking at the code:
https://github.com/apache/parquet-mr/blob/master/parquet-avro/src/main/java/org/apache/parquet/avro/AvroIndexedRecordConverter.java#L236-L238

FieldEnumConverter falls back to a string representation when it can't find the corresponding enum class. This is problematic when trying to read parquet files generically without specific records on the classpath because the records will no longer match the schema. I believe a more correct approach would be to wrap the enums in GenericData.EnumSymbol:
https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java#L397

**Reporter**: [Igor Bernstein](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=igorbernstein)

**Note**: *This issue was originally created as [PARQUET-557](https://issues.apache.org/jira/browse/PARQUET-557). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in parquet-avro/src/main/java/org/apache/parquet/avro/AvroIndexedRecordConverter.java at the FieldEnumConverter code around lines 236-238, then compare the referenced GenericData.EnumSymbol behavior in Avro's GenericData.java. Verify generic-record reads preserve the enum schema representation rather than falling back to a string; the issue is done when the resulting records match the schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.