Skip to content

fix(parquet/pqarrow): normalize the element name in the stored ARROW:schema - #746

Merged
zeroshade merged 5 commits into
apache:mainfrom
zeroshade:parquet-schema-normalization
Apr 17, 2026
Merged

zeroshade merged 5 commits into
apache:mainfrom
zeroshade:parquet-schema-normalization

Conversation

@zeroshade

Copy link
Copy Markdown
Member

Rationale for this change

closes #744

What changes are included in this PR?

Normalizes the element name of list fields in the stored ARROW:schema of a parquet file to avoid mismatches.

Are these changes tested?

Yes, a new unit test is added.

Are there any user-facing changes?

Yes, should be a bug fix to ensure consistency.

The lint fix in the previous commit incorrectly transformed the condition:
  !(A && !B && C)  ->  (nil || !B && !IsNone || !C)

The correct transformation is:
  nil || B || !C

Also restores use of n.decimalMetaData instead of DecimalMetadata{} in the
IsCompatible call, which was also changed incorrectly.
Comment thread parquet/pqarrow/file_writer.go Outdated
// Specifically, list element field names are set to "element" because
// ListOfWithName (used by fieldToNode) always names the Parquet element group
// "element", regardless of the original Arrow element field name.
func normalizeFieldForParquet(f arrow.Field) arrow.Field {

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.

Do we need to recurse down into run-end-encoded arrays and listviews and such too? (Should we use NestedType so we don't have to hardcode all the nested types every time we want to do structural recursion like this?)

@zeroshade zeroshade Apr 14, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We haven't implemented handling for run-end-encoded or list-views yet for pqarrow, so I'm okay putting that off to add here until we add that support.

For NestedType: it gives us Fields()/NumFields() for recursion but no generic reconstruction path. We'd still need type-specific cases to rebuild each type (e.g. ListOfField vs FixedSizeListOfField vs StructOf). So the switch here is likely better than trying to use NestedType and then having to switch on which nested type anyways.

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.

Fair enough. Can we explicitly bail out so there's no chance of forgetting to update this later on? (I think we might consider a generic traverser API, this need comes up often enough, but apart from arrow-java this is something lacking from other major Arrow implementations too AFAIK 😅)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated to explicitly bail

@zeroshade
zeroshade requested a review from lidavidm April 16, 2026 16:26
@zeroshade
zeroshade merged commit a97bd0b into apache:main Apr 17, 2026
23 checks passed
@zeroshade
zeroshade deleted the parquet-schema-normalization branch April 24, 2026 17:30
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.

Difference between arrow-go and pyarrow file writer

2 participants