Skip to content

fix(parquet/pqarrow): prefer stored schema extension type on read - #1051

Merged
zeroshade merged 3 commits into
apache:mainfrom
twuebi:fix/pqarrow-prefer-origin-extension
Aug 5, 2026
Merged

zeroshade merged 3 commits into
apache:mainfrom
twuebi:fix/pqarrow-prefer-origin-extension

Conversation

@twuebi

@twuebi twuebi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Rationale

Since #1028, the reader reconstructs an extension type directly from a Parquet logical type (via ArrowTypeFromParquet), so the inferred field can now be an extension type rather than the bare storage type it used to be. applyOriginalStorageMetadata still assumed the inferred type was plain storage when reconciling against the stored ARROW:schema, so when the two extension instances differed it fell into the "wrap the storage type" branch, found an extension instead of the storage type, and raised a spurious storage-type mismatch.

This surfaces with GeoArrow WKB: an authority_code CRS (e.g. the default OGC:CRS84) round-trips through Parquet's opaque CRS string and comes back tagged srid, so the inferred WKBType differs from the one stored in ARROW:schema. Reading any such file — even though the stored schema is authoritative and correct — failed with:

invalid: mismatch storage type 'extension_type<storage=binary>' for extension type 'extension_type<storage=binary>'

Fix

In applyOriginalStorageMetadata's extension branch, when the inferred type is already an extension of the same name as the origin's, adopt the origin's (authoritative) parameters instead of requiring the inferred type to be the bare storage type.

Testing

Existing pqarrow extension/geospatial/store-schema tests pass; verified end-to-end that a GeoArrow WKB file with default-CRS (authority_code) columns and a stored ARROW:schema now reads back correctly.

twuebi added 2 commits July 29, 2026 11:38
When a Parquet file carries both a stored ARROW:schema and a logical type
that a registered extension recovers on read, the inferred field can already
be an extension type rather than the bare storage type. In that case
applyOriginalStorageMetadata rejected the file with a spurious storage-type
mismatch even though the stored schema is authoritative.

Prefer the origin extension when the inferred type is an extension of the
same name, so reads honor the stored schema's parameters.
@twuebi
twuebi requested a review from zeroshade as a code owner July 29, 2026 09:55
@zeroshade
zeroshade merged commit 86a7280 into apache:main Aug 5, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants