Repository navigation
Read big-endian Arrow IPC files and streams - #126562
Conversation
The native reader rejected every big-endian file. Byte-swap the buffers of a big-endian batch to little-endian before decoding, as Arrow C++ does: walk the batch layout with `advanceField`, which knows each buffer's element width, and reverse each element in place. Day-time and month-day-nano intervals are swapped per component, binary views per integer field, fixed-size binary not at all. The uncompressed body is copied once first, since it belongs to the caller. Closes: ClickHouse#125138
|
Workflow [PR], commit [efbc256] Summary: ✅
AI ReviewSummaryThe PR enables big-endian Arrow IPC input by converting record-batch and dictionary buffers before decoding, with corpus tests covering schemas, sample values, and hashes of all rows. No actionable correctness or safety findings were identified. Missing context / blind spots
Final Verdict✅ Approve on code review; the new regression test still needs its normal stateless CI run. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units9 translation units recompiled, 24 s compile time in total, 9 of them have a recent master baseline. |
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: #125138
Related: #125134
The native Arrow IPC reader rejected every big-endian file and stream (
Big-endian Arrow IPC streams are not supported by the native reader). Arrow records the endianness in the schema, and readers may byte-swap the buffers, as Arrow C++ does. This PR does that:prepareBufferscopies the uncompressed body of a big-endian batch once, since the body belongs to the caller (a compressed body is already decompressed intodecompressed_body). It copies the whole body rather than each buffer, so overlapping buffers in a malformed file cannot multiply the allocation.convertBuffersFromBigEndianwalks the batch layout withadvanceField, which already knows each buffer's element width, and byte-swaps every buffer it passes, then rewinds the cursors. It runs for record batches and for dictionary batches.The test reads the big-endian integration files of
apache/arrow-testing(data/arrow-ipc-stream/integration/1.0.0-bigendian, commit9ff285c8): 17 streams and one file in theArrowformat, covering primitives with 32- and 64-bit offsets, dates and times, decimals of 128 and 256 bits, dictionaries (also nested and unsigned), lists, maps, structs and extension types. The two decimal streams are cut to their schema and first record batch, keeping the messages byte for byte, to keep the files small. The reference is the output of the current master build for the little-endian versions of the same files: the schema, the first rows, and a hash of every row.The corpus files whose little-endian versions cannot be read yet (
interval,union,null,duplicate_fieldnames) are left out. When #125134 is merged, the big-endian lines of its05361_arrow_testing_corpus.referencewill need the new output.List-view buffers are not swapped here because master only skips list views; #126014 adds their decoding, and whichever of the two is merged second will add the swap for their offsets and sizes.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The native Arrow IPC reader can read big-endian Arrow files and streams.
Workflow [PR]
Sync PR [sync-upstream/pr/126562]
Version info
26.11.1.350-master(included in26.11and later)