Repository navigation
Pack Arrow Duration dictionary values via Int64 reinterpretation - #12349
lwwmanning wants to merge 2 commits into
Conversation
arrow_cast's dictionary packing omits Arrow Duration types, preventing sparse Duration dictionary slices from repacking into Arrow dictionaries. Reinterpret Duration values as Int64, pack via arrow_cast, and reinterpret the resulting dictionary values back to Duration without copying. Co-Authored-By: Antigravity <noreply@google.com> Signed-off-by: Will Manning <will@willmanning.io>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
lwwmanning
left a comment
There was a problem hiding this comment.
Posted by Claude Opus 5.5 on Will's behalf.
The fix is correct, and the split from #12337 is clean. Two points.
From reading the code, on develop this does more than bloat sparse slices. decode_to_dictionary calls arrow_cast::cast to Dictionary(K, Duration), which arrow-cast does not support, so every Duration input that reaches it fails. For example, a canonical Duration extension array exported with a Dictionary(Int32, Duration(Millisecond)) field takes that path and errors. Could the description lead with that? Could the test also add one case for it, such as a plain Duration array, or two Duration dictionaries whose joined values overflow Int8 keys?
The two unit matches can go. The arrow-cast crate packs Timestamp and the time types this way in pack_array_to_dictionary_via_primitive. It also supports Duration to Int64 (a reinterpret) and Int64 to Duration. So cast(&array, Int64), then cast(.., Dictionary(K, Int64)), then cast(.., Dictionary(K, Duration(unit))) does the same thing in about 8 lines. It needs no ArrowTimeUnit import and no manual DictionaryArray::try_new. The last cast touches only the deduplicated values.
…ration export Replace the per-TimeUnit reinterpret matches and manual DictionaryArray construction with arrow_cast casts through Int64 and Dictionary(K, Int64), and add a regression test for exporting a plain Duration array to an Arrow dictionary field. Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Addressed both points in a2d70d1: replaced the per- |
arrow_castdoes not support packingDurationarrays directly intoDictionary(K, Duration(_)), so anyDurationinput that reachesdecode_to_dictionary(such as a plainDurationarray exported to a dictionary field or joined dictionaries overflowing key width) fails ondevelop, and sparseDurationdictionary slices cannot repack. Since ArrowDurationsharesInt64's physical layout,decode_to_dictionarynow castsDurationtoInt64, packs intoDictionary(K, Int64), and casts the deduplicated dictionary values back toDuration.Assisted by Antigravity and Devin.