Repository navigation
Pack Arrow Duration dictionary values via Int64 reinterpretation - #12349
lwwmanning wants to merge 1 commit 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.
arrow_cast's dictionary packing omits ArrowDurationtypes, preventing sparseDurationdictionary slices from repacking into Arrow dictionaries. Since ArrowDurationarrays share the exacti64physical layout ofInt64,decode_to_dictionarynow reinterpretsDurationvalues asInt64, packs viaarrow_cast, and reinterprets the dictionary values back toDurationwithout copying.Assisted by Antigravity and Devin.