Skip to content

Parquet: Fix Variant conversion in default Avro writer - #17944

Open
2dmurali wants to merge 1 commit into
apache:mainfrom
2dmurali:fix/parquet-variant-avro-writer
Open

Parquet: Fix Variant conversion in default Avro writer#17944
2dmurali wants to merge 1 commit into
apache:mainfrom
2dmurali:fix/parquet-variant-avro-writer

Conversation

@2dmurali

@2dmurali 2dmurali commented Sep 4, 2026

Copy link
Copy Markdown

Problem

The default Parquet Avro writer registers VariantConversion, but conversion lookup does not recognize implementations of the Variant interface.

Values created using Variant.of(...) have the runtime type VariantData. Avro's exact-class conversion lookup therefore misses the conversion registered for Variant.class and attempts to handle the value as an IndexedRecord, causing a ClassCastException.

Changes

  • Use VariantConversion for logical Variant values whose runtime classes implement Variant.
  • Add a regression test that writes a GenericData.Record through the default Parquet writer and verifies the Variant value after reading it back.

Testing

  • ./gradlew :iceberg-parquet:test
  • ./gradlew spotlessCheck
  • ./gradlew build -x test -x integrationTest
  • Manually reproduced the failure and verified the fix using the Iceberg Spark 4.0 runtime.

Closes #17943

@2dmurali

2dmurali commented Sep 4, 2026

Copy link
Copy Markdown
Author

Hi @nssalian could you take a look at this PR? I noticed you've been actively driving the Variant type feature, so I'd really appreciate your thoughts and review when you have a chance. Thanks!

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix seems very scoped, and makes sense to me! Thank you @2dmurali, definitely ping relevant committers who have more context here

@nssalian nssalian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @2dmurali. LGTM. I reverted the fix locally and confirmed the test fails with the ClassCastException regression, and passes with the fix. I'll tag folks who can merge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parquet: Default Avro writer fails to write Variant values

3 participants