Repository navigation
Read Arrow structs with empty or repeated field names as unnamed Tuple - #125674
alexey-milovidov merged 4 commits into
Conversation
|
Workflow [PR], commit [e884a5f] Summary: ✅
AI ReviewSummaryThe PR reads Arrow structs with invalid tuple element names as unnamed Missing context / blind spots
Final VerdictStatus: ✅ Approve. No additional code changes requested. |
…hints and dictionary uses The library reader is left as it was: it also serves Parquet, where struct fields are mapped by name.
A struct with empty or repeated field names is read as an unnamed `Tuple`, which `prepareArrowColumnForCast` matches by position, but `alignStructFieldNamesCaseInsensitive` stopped at it. A named struct nested inside then kept its original field names, so with `input_format_arrow_case_insensitive_column_matching` its differently-cased fields became default values. Descend by position there too.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units435 translation units recompiled, 3362 s compile time in total, 435 of them have a recent master baseline. |
|
This is great, thank you! |
Resolve the conflicts of the cherry-pick of #132416 to 26.9. The fix applies in full; the differences from the original diff come only from master-only neighbours that 26.9 does not have: - `ArrowIPCBlockInputFormat.cpp`: 26.9 still checks that dictionary values are unique after registering them (master dropped the check in #125677). Keep the check and look the values up by the dictionary use, as the registry is now keyed by it. - `RecordBatchDecoder.cpp`: 26.9 has no `TypeKind::RunEndEncoded` case in `collectDictionaryUses` (run-end encoding, #126207, is master-only), so there is no call to pass `below_union` to there. The struct case keeps the 26.9 helpers `tupleElementHint` / `childPath` (master renamed them in #125674) and passes `below_union` as the original change does. - `RecordBatchDecoder.cpp`: include `base/scope_guard.h` for the two new `SCOPE_EXIT` uses. On master the include came with the big-endian reader (#126562); 26.9 does not include it, directly or transitively. - `RecordBatchDecoder.h`: no `[[nodiscard]]` on the changed declarations, as on the rest of the 26.9 file (master added them in #126158). Co-authored-by: yakov <[email protected]>
Resolve the conflicts of the cherry-pick of #132416 to 26.10. The fix applies in full; the differences from the original diff come only from master-only neighbours that 26.10 does not have: - `RecordBatchDecoder.cpp`: 26.10 has no `TypeKind::RunEndEncoded` case in `collectDictionaryUses` (run-end encoding, #126207, is master-only), so there is no call to pass `below_union` to there. The struct case keeps the 26.10 helpers `tupleElementHint` / `childPath` (master renamed them in #125674) and passes `below_union` as the original change does. - `RecordBatchDecoder.cpp`: include `base/scope_guard.h` for the two new `SCOPE_EXIT` uses. On master the include came with the big-endian reader (#126562); 26.10 does not include it, directly or transitively. - `RecordBatchDecoder.h`: no `[[nodiscard]]` on the changed declarations, as on the rest of the 26.10 file (master added them in #126158). Co-authored-by: yakov <[email protected]>
Closes: #125141
Arrow allows struct fields with empty or repeated names, but a named
Tuplecannot have them, so schema inference failed withNames of tuple elements cannot be empty. The native Arrow IPC reader now reads such a struct as an unnamedTuple, and matches its fields by position everywhere it used their names:SchemaConvertermarks the struct withArrowType::positional_fieldswhen it parses the schema (usingDataTypeTuple::hasValidElementNames, which exposes the existing check: non-empty, unique, notnull), andfieldToCHTypereturns an unnamedTuplefor it.RecordBatchDecodertakes the requested type of each field by position (structFieldHint), also when the requestedTupleis named, and identifies the field by its 1-based position in the dictionary-use paths (structFieldPath), so two equally named fields sharing a dictionary keep their own requested types.reinterpretRawBytes) matches the fields of an unnamed decodedTupleby position too.The Apache Arrow library based reader (
ArrowColumnToCHColumn, used by Arrow Flight, Delta Lake and Parquet) is not changed: it maps struct fields by name, including through Parquet column names, and still rejects such structs.The test reads a small file written with
pyarrowthat has a struct with two empty field names, a struct with a repeated name, a normal struct and a map, in both theArrowandArrowStreamformats, with inferred, unnamed and named requested types. It also checks afixed_size_binary(16)field with an empty name requested asUInt128in a namedTuple, and two fields namedxthat share onedate32dictionary, requested asTuple(Int64, Date32)(the second one is still range-checked asDate32).The top-level duplicate column names in the same
arrow-testingfile are a separate issue (#125140) and are not changed here.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
ArrowandArrowStreaminput formats read struct columns whose fields have empty or repeated names as an unnamedTupleinstead of failing schema inference.Workflow [PR]
Sync PR [sync-upstream/pr/125674]
Version info
26.11.1.715-master(included in26.11and later)