Skip to content

fix(parquet): return error instead of panicking on Union and invalid time units - #12549

Open
cvp2004 wants to merge 1 commit into
apache:mainfrom
cvp2004:fix/parquet-union-schema-error
Open

cvp2004 wants to merge 1 commit into
apache:mainfrom
cvp2004:fix/parquet-union-schema-error

Conversation

@cvp2004

@cvp2004 cvp2004 commented Dec 4, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

ArrowWriter::try_new and ArrowSchemaConverter::convert panic on a schema with a Union field (top-level or nested), and on the invalid units Time32(Microsecond | Nanosecond) and Time64(Second | Millisecond). The try_new docs say unsupported types such as unions make it fail, so they should return an error.

What changes are included in this PR?

In arrow_to_parquet_type:

  • Union returns ParquetError::NYI("Datatype ... is not yet supported"), the same error the writer already returns for a union reached through an explicit Parquet schema.
  • Invalid Time32 / Time64 units return an ArrowError instead of hitting unreachable!.

Are these changes tested?

Yes. test_union_field_returns_error covers a union at the top level and inside a struct, list and dictionary, through both ArrowSchemaConverter and ArrowWriter::try_new. test_invalid_time_unit_returns_error covers the four invalid units. Both tests panic without the fix.

Are there any significant user-facing changes?

No. Calls that used to panic now return an error.

AI usage disclosure

I used Claude Code to draft the fix and the tests. I reviewed the change, checked that the tests fail without the fix, and ran the parquet checks locally.

…time units

ArrowSchemaConverter (and so ArrowWriter::try_new) now returns NYI for Union
fields and an error for invalid Time32/Time64 units, instead of panicking.
@boring-cyborg boring-cyborg Bot added the parquet parquet crate label Dec 4, 2026

@etseidl etseidl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks reasonable to me, thanks.

))
}
}
DataType::Union(_, _) => unimplemented!("See ARROW-8817."),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems to have migrated to #73 and is still open. we should at least note it in a comment here

This branch has not been deployed

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

Labels

parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parquet: ArrowWriter::try_new panics on a schema with a Union field instead of returning an error

2 participants