Skip to content

Move temporal cast helpers into a private submodule - #11075

Open
anandghegde wants to merge 1 commit into
apache:mainfrom
anandghegde:extract-temporal-cast-helpers
Open

anandghegde wants to merge 1 commit into
apache:mainfrom
anandghegde:extract-temporal-cast-helpers

Conversation

@anandghegde

Copy link
Copy Markdown

Which issue does this PR close?

Part of #11032 — this is the temporal helpers group only, so it does not
close the issue. The remaining groups (numeric/boolean, binary/byte-view,
struct, decimal adapters) are untouched here. @amitvijapur mentioned taking the
struct group; this branch does not touch it.

Rationale for this change

arrow-cast/src/cast/mod.rs is ~14k lines. #5125 moved list, decimal,
dictionary, string, map, run-array and union support into private submodules,
and #11032 captures the groups still left inline. The timestamp, date,
duration, interval and timezone helpers are one such cohesive group.

What changes are included in this PR?

A new private arrow-cast/src/cast/temporal.rs holding:

  • cast_interval_year_month_to_interval_month_day_nano
  • cast_interval_day_time_to_interval_month_day_nano
  • cast_month_day_nano_to_duration
  • cast_duration_to_interval
  • make_timestamp_array, make_duration_array
  • as_time_res_with_timezone
  • timestamp_to_date32
  • adjust_timestamp_to_timezone

cast_with_options stays the top-level dispatcher in mod.rs.

Two things worth flagging for review:

  • cast_reinterpret_arrays deliberately stays in mod.rs. It sits in the
    middle of this block, so it looks like part of the group, but it is a generic
    PrimitiveArray::reinterpret_cast wrapper with 23 call sites across the
    numeric, temporal and dictionary paths — not temporal-specific.
  • The helpers became pub(crate), which is what they need to stay reachable
    from mod.rs through the glob import, matching string.rs and list.rs.
    Nothing new is exposed outside the crate.

The bodies are moved verbatim. I checked this mechanically rather than by eye:
extracting the three original line ranges from HEAD and normalising away the
pub(crate) prefix gives a byte-identical match against the new file.

Are these changes tested?

Covered by the existing arrow-cast tests — this is a code move, so no new
tests are warranted and no test was modified.

cargo test -p arrow-cast     379 passed + 12 passed, 0 failed (same as base)
cargo clippy -p arrow-cast --all-targets -- -D warnings   clean
cargo fmt -p arrow-cast -- --check                        clean
cargo build -p arrow                                      builds

Run on macOS 26.6.2, aarch64-apple-darwin, toolchain 1.98.1 from
rust-toolchain.toml.

Are there any user-facing changes?

No. No public API change, no behavioural change. Everything moved is private to
the crate, and the two mod.rs imports dropped (IntervalMonthDayNano, and
NaiveTime/Offset from chrono) were orphaned by the move.

AI usage disclosure

Written with AI assistance (Claude). The AI performed the mechanical extraction
and ran the verification above; I reviewed the result and own the change.

To be concrete about what that means here, since the value of a code move is
entirely in it being faithful: the moved bodies are unedited, and the
byte-identity check described above is the evidence for that rather than a
reading. The two judgement calls — leaving cast_reinterpret_arrays behind, and
the pub(crate) visibility — are called out above precisely because they are the
parts a diff of a "pure move" would not otherwise draw attention to.

Follow-up to apache#5125, continuing the extractions in apache#5537 and friends.

`arrow-cast/src/cast/mod.rs` still holds the timestamp, date, duration,
interval and timezone helpers. Move them into a private `temporal`
submodule, leaving `cast_with_options` as the top-level dispatcher.

The function bodies are moved verbatim; the only edit is the `pub(crate)`
visibility they need to stay reachable from `mod.rs`, matching the
convention in `string.rs` and `list.rs`. `cast_reinterpret_arrays` stays
in `mod.rs`: it sat inside this block but is a generic primitive helper
used across the numeric, temporal and dictionary paths.

No behavioural change and no public API change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-cast

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant