Validating logical slice alignment in Arrow dense unions
An in-range offset can still select the wrong child value after two input windows become misaligned.
Valid offsets can identify the wrong logical value
Treat offset bounds and alignment of logical buffer windows as separate contracts. A referenced child position can be structurally valid while belonging to the wrong logical row. Separate structural validation from value selection to detect misaligned zero-copy slices. [1, 2, 3]
Logical offsets [1, 2] read as [0, 1]
The Arrow C++ main reproduction slices value_offsets to logical [1, 2], yet the constructed union returns [10, 20]. With child values [10, 20, 30], the expected result is [20, 30]. ValidateFull succeeds because the offsets actually read remain within the child bounds. A related sparse-union report points to the same offset-alignment cause; this control is limited to dense-union value selection. [1]
Bind both input windows
Record logical lengths and start positions for type_ids and value_offsets and align them before union construction. Compare resulting values with an independent index reference. Distinguish backing-buffer starts from slice starts, and reject a value_offsets array shorter than type_ids before attempting value comparison. [1, 3]
A failing first-child example
Define illustrative child values [10, 20, 30] and first logical offset 1. Independent indexing establishes expected value 20. A union value of 20 passes; 10 fails. Ten is also a valid child value, which is precisely why a range-only check cannot distinguish the error. [1, 3]
The comparison table for Truthound
Truthound Core's ColumnPairValidator can compare expected_child_value, independently selected from logical_value_offset, with union_value. Prepare the logical-window reference calculation and row alignment separately. Passing does not establish buffer lifetime or zero-copy memory safety and does not replace length and alignment checks. [1, 2, 3]
Application conditions
Prepare row_id, logical_value_offset, expected_child_value and union_value from original data or an independent index reference, aligned to the same run, file and key scope.
Alternatives
Use a supported construction path that aligns buffers to their logical windows before creating the union.
Limitations
Truthound does not manage zero-copy buffer lifetime. The related sparse-union report provides additional evidence of the same cause, not an independent cause confirmation.
Evidence
- Event checked
- Subject checked
- Modified
