Move numeric and boolean cast helpers into a private submodule - #11076
Open
anandghegde wants to merge 1 commit into
Open
anandghegde wants to merge 1 commit into
anandghegde wants to merge 1 commit into
Conversation
Follow-up to apache#5125, continuing the extractions in apache#5537 and friends. Move the numeric and boolean conversion helpers out of `arrow-cast/src/cast/mod.rs` into a private `numeric` submodule, leaving `cast_with_options` as the top-level dispatcher. The bodies are moved verbatim. `num_cast`, `cast_num_to_bool` and `single_bool_to_numeric` stay `pub` and are re-exported with `pub use crate::cast::numeric::*`, so `arrow_cast::cast::num_cast` and the other two keep their existing paths. The three helpers the dispatcher calls become `pub(crate)`; the rest stay private to the new module. No behavioural change and no public API change.
This was referenced Sep 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #11032 — the numeric and boolean conversion helpers group only, so it
does not close the issue.
Sibling PRs against the same issue: #11075 (temporal helpers). The two are
independent and touch disjoint parts of
mod.rs, but both add amodline andan import, so whichever lands second will want a trivial rebase.
Rationale for this change
arrow-cast/src/cast/mod.rsis ~14k lines. #5125 moved list, decimal,dictionary, string, map, run-array and union support into private submodules,
and #11032 lists the groups still inline. The numeric and boolean conversions
are one of them.
What changes are included in this PR?
A new
arrow-cast/src/cast/numeric.rsholding:cast_numeric_arrays,try_numeric_cast,num_cast,numeric_castcast_numeric_to_bool,numeric_to_bool_cast,cast_num_to_boolcast_bool_to_numeric,bool_to_numeric_cast,single_bool_to_numericcast_with_optionsstays the top-level dispatcher inmod.rs.Worth flagging for review:
num_cast,cast_num_to_boolandsingle_bool_to_numericarepub, somod.rsre-exports the module withpub use crate::cast::numeric::*(the same shape already used forunion).arrow_cast::cast::num_castand the other two resolve exactly as before.dispatcher actually calls —
cast_numeric_arrays,cast_numeric_to_bool,cast_bool_to_numeric— becamepub(crate).try_numeric_cast,numeric_cast,numeric_to_bool_castandbool_to_numeric_casthave nocallers outside the moved code and stay private to the new module.
mod.rs.cast_numeric_to_binaryandadjust_timestamp_to_timezonesit between the numeric and boolean halves andbelong to other groups, so they are left where they are.
Are these changes tested?
Covered by the existing
arrow-casttests — this is a code move, so no newtests are warranted and no existing test was modified.
Two checks beyond the suite, because a code move is only worth anything if it is
faithful and the public paths survive:
HEADand normalising away theadded
pub(crate)gives a byte-identical match against the new file.arrow_cast::cast::num_cast,::cast_num_to_booland::single_bool_to_numericthrough their public pathscompiles and passes. It is not part of this diff — it existed only to confirm
the re-export, and was removed.
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 and no behavioural change.
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.
The moved bodies are unedited, and the byte-identity check is the evidence for
that rather than a reading. The judgement calls — which helpers need
pub(crate), which stay private, keeping the two interleaved functions fromother groups in place, and re-exporting to preserve the public paths — are
listed above because they are exactly the parts a "pure move" diff would not
otherwise draw attention to.