anandghegde opened a new pull request, #11076:
URL: https://github.com/apache/arrow-rs/pull/11076
# 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 a `mod` line
and
an import, so whichever lands second will want a trivial rebase.
# 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 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.rs` holding:
- `cast_numeric_arrays`, `try_numeric_cast`, `num_cast`, `numeric_cast`
- `cast_numeric_to_bool`, `numeric_to_bool_cast`, `cast_num_to_bool`
- `cast_bool_to_numeric`, `bool_to_numeric_cast`, `single_bool_to_numeric`
`cast_with_options` stays the top-level dispatcher in `mod.rs`.
Worth flagging for review:
- **The public API is unchanged.** `num_cast`, `cast_num_to_bool` and
`single_bool_to_numeric` are `pub`, so `mod.rs` re-exports the module with
`pub use crate::cast::numeric::*` (the same shape already used for
`union`).
`arrow_cast::cast::num_cast` and the other two resolve exactly as before.
- **Visibility is minimal rather than uniform.** Only the three helpers the
dispatcher actually calls — `cast_numeric_arrays`, `cast_numeric_to_bool`,
`cast_bool_to_numeric` — became `pub(crate)`. `try_numeric_cast`,
`numeric_cast`, `numeric_to_bool_cast` and `bool_to_numeric_cast` have no
callers outside the moved code and stay private to the new module.
- **The group is not contiguous in `mod.rs`.** `cast_numeric_to_binary` and
`adjust_timestamp_to_timezone` sit between the numeric and boolean halves
and
belong to other groups, so they are left where they are.
# Are these changes tested?
Covered by the existing `arrow-cast` tests — this is a code move, so no new
tests are warranted and no existing 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
```
Two checks beyond the suite, because a code move is only worth anything if
it is
faithful and the public paths survive:
- Extracting the two original line ranges from `HEAD` and normalising away
the
added `pub(crate)` gives a **byte-identical** match against the new file.
- A temporary integration test calling `arrow_cast::cast::num_cast`,
`::cast_num_to_bool` and `::single_bool_to_numeric` through their public
paths
compiles 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 from
other 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]