Repository navigation
fix(parquet/pqarrow): normalize the element name in the stored ARROW:schema - #746
Conversation
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.
| // 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 { |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😅)
There was a problem hiding this comment.
Updated to explicitly bail
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.