Skip to content

Pack Arrow Duration dictionary values via Int64 reinterpretation - #12349

Open
lwwmanning wants to merge 1 commit into
developfrom
wm/pack-arrow-duration-dicts
Open

lwwmanning wants to merge 1 commit into
developfrom
wm/pack-arrow-duration-dicts

Conversation

@lwwmanning

Copy link
Copy Markdown
Contributor

arrow_cast's dictionary packing omits Arrow Duration types, preventing sparse Duration dictionary slices from repacking into Arrow dictionaries. Since Arrow Duration arrays share the exact i64 physical layout of Int64, decode_to_dictionary now reinterprets Duration values as Int64, packs via arrow_cast, and reinterprets the dictionary values back to Duration without copying.

Assisted by Antigravity and Devin.

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>
@lwwmanning lwwmanning added the changelog/fix A bug fix label Nov 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T00:21:37.421939Z 3ff5d91 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant