Split arrow_cast::cast struct helpers into their own submodule - #11074
Merged
Jefffrey merged 2 commits intoSep 17, 2026
Merged
Conversation
Moves cast_struct_to_struct, cast_struct_fields_by_name and cast_struct_fields_in_order out of cast/mod.rs into a private structs submodule, following the shape of apache#5537. No behaviour change; cast_with_options remains the dispatcher. Part of apache#11032.
sdf-jkl
approved these changes
Sep 15, 2026
Contributor
Author
|
Thanks for the review @sdf-jkl. This is my first PR to arrow-rs, so the workflow runs are waiting on approval (all nine at |
Member
|
Thanks @amitvijapur, I saw that. I was hoping to wait on #11097 to avoid burning compute on MIRI |
Jefffrey
approved these changes
Sep 17, 2026
Contributor
i think we can proceed for now as it might take some time to get merge queue in, but i think we'll try to prioritize getting #11097 in 👍 |
Contributor
|
thanks @amitvijapur & @sdf-jkl |
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 18, 2026
…e#11074) # Which issue does this PR close? Part of apache#11032. Takes the **struct conversion helpers** group; the other four groups are left for separate PRs as the issue asks. # Rationale for this change `arrow-cast/src/cast/mod.rs` is 14,312 lines. apache#5125 and its follow-ups (apache#5537, apache#5552, apache#5555, apache#5563) moved list, decimal, dictionary, string, map, run-array and union casting into private submodules. The struct helpers are a small cohesive group still sitting in `mod.rs`, so this continues that series in the same shape. # What changes are included in this PR? - New private module `arrow-cast/src/cast/structs.rs` containing `cast_struct_to_struct`, `cast_struct_fields_by_name` and `cast_struct_fields_in_order`, moved from `mod.rs`. - `mod structs;` and `use crate::cast::structs::*;` added to `mod.rs` in alphabetical position, matching how the existing submodules are wired. - `cast_struct_to_struct` becomes `pub(crate)` because `cast_with_options` calls it from `mod.rs`. The other two are only called from within the new file and stay plain `fn`, following `list.rs`, which keeps its inner helper private. - `cast_with_options` is untouched and remains the dispatcher; the call site at `mod.rs:1233` is byte-identical to `main`. The module is named `structs` because `struct` is a keyword. Happy to rename to `struct_array` or anything else if preferred. No behaviour change. To verify that mechanically rather than by inspection: taking the lines removed from `mod.rs` and diffing them against the body of `structs.rs` with the one `pub(crate)` prefix stripped, the only difference is the blank line that separated the last helper from `cast_from_decimal`, which correctly stays in `mod.rs`. The 67 lines of code, including comments and wrapping, are identical. # Are these changes tested? By the existing tests. `test_cast_struct_to_struct`, `test_cast_struct_to_struct_nullability` and the other `cast_struct_*` tests exercise these helpers through the public `cast` API and are unchanged. - `cargo test -p arrow-cast --lib`: 379 passed, 0 failed - `cargo clippy -p arrow-cast --all-targets --all-features -- -D warnings`: clean - `cargo fmt --all -- --check`: clean - `cargo doc -p arrow-cast --no-deps`: none of the three helper names appear in the generated docs, confirming nothing new is exported # Are there any user-facing changes? No. The three functions were private before and remain crate-private; `structs` is a private module and the glob import is not `pub use`. # AI usage disclosure Per CONTRIBUTING.md: the extraction was performed with Claude Code assistance. The moved code is the existing upstream code, not generated. AI was used to locate the helper group, perform the mechanical move, and run the verification above. I reviewed the full diff and the verification output before opening this. Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 21, 2026
…e#11074) # Which issue does this PR close? Part of apache#11032. Takes the **struct conversion helpers** group; the other four groups are left for separate PRs as the issue asks. # Rationale for this change `arrow-cast/src/cast/mod.rs` is 14,312 lines. apache#5125 and its follow-ups (apache#5537, apache#5552, apache#5555, apache#5563) moved list, decimal, dictionary, string, map, run-array and union casting into private submodules. The struct helpers are a small cohesive group still sitting in `mod.rs`, so this continues that series in the same shape. # What changes are included in this PR? - New private module `arrow-cast/src/cast/structs.rs` containing `cast_struct_to_struct`, `cast_struct_fields_by_name` and `cast_struct_fields_in_order`, moved from `mod.rs`. - `mod structs;` and `use crate::cast::structs::*;` added to `mod.rs` in alphabetical position, matching how the existing submodules are wired. - `cast_struct_to_struct` becomes `pub(crate)` because `cast_with_options` calls it from `mod.rs`. The other two are only called from within the new file and stay plain `fn`, following `list.rs`, which keeps its inner helper private. - `cast_with_options` is untouched and remains the dispatcher; the call site at `mod.rs:1233` is byte-identical to `main`. The module is named `structs` because `struct` is a keyword. Happy to rename to `struct_array` or anything else if preferred. No behaviour change. To verify that mechanically rather than by inspection: taking the lines removed from `mod.rs` and diffing them against the body of `structs.rs` with the one `pub(crate)` prefix stripped, the only difference is the blank line that separated the last helper from `cast_from_decimal`, which correctly stays in `mod.rs`. The 67 lines of code, including comments and wrapping, are identical. # Are these changes tested? By the existing tests. `test_cast_struct_to_struct`, `test_cast_struct_to_struct_nullability` and the other `cast_struct_*` tests exercise these helpers through the public `cast` API and are unchanged. - `cargo test -p arrow-cast --lib`: 379 passed, 0 failed - `cargo clippy -p arrow-cast --all-targets --all-features -- -D warnings`: clean - `cargo fmt --all -- --check`: clean - `cargo doc -p arrow-cast --no-deps`: none of the three helper names appear in the generated docs, confirming nothing new is exported # Are there any user-facing changes? No. The three functions were private before and remain crate-private; `structs` is a private module and the glob import is not `pub use`. # AI usage disclosure Per CONTRIBUTING.md: the extraction was performed with Claude Code assistance. The moved code is the existing upstream code, not generated. AI was used to locate the helper group, perform the mechanical move, and run the verification above. I reviewed the full diff and the verification output before opening this. Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
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. Takes the struct conversion helpers group; the other four groups are left for separate PRs as the issue asks.
Rationale for this change
arrow-cast/src/cast/mod.rsis 14,312 lines. #5125 and its follow-ups (#5537, #5552, #5555, #5563) moved list, decimal, dictionary, string, map, run-array and union casting into private submodules. The struct helpers are a small cohesive group still sitting inmod.rs, so this continues that series in the same shape.What changes are included in this PR?
arrow-cast/src/cast/structs.rscontainingcast_struct_to_struct,cast_struct_fields_by_nameandcast_struct_fields_in_order, moved frommod.rs.mod structs;anduse crate::cast::structs::*;added tomod.rsin alphabetical position, matching how the existing submodules are wired.cast_struct_to_structbecomespub(crate)becausecast_with_optionscalls it frommod.rs. The other two are only called from within the new file and stay plainfn, followinglist.rs, which keeps its inner helper private.cast_with_optionsis untouched and remains the dispatcher; the call site atmod.rs:1233is byte-identical tomain.The module is named
structsbecausestructis a keyword. Happy to rename tostruct_arrayor anything else if preferred.No behaviour change. To verify that mechanically rather than by inspection: taking the lines removed from
mod.rsand diffing them against the body ofstructs.rswith the onepub(crate)prefix stripped, the only difference is the blank line that separated the last helper fromcast_from_decimal, which correctly stays inmod.rs. The 67 lines of code, including comments and wrapping, are identical.Are these changes tested?
By the existing tests.
test_cast_struct_to_struct,test_cast_struct_to_struct_nullabilityand the othercast_struct_*tests exercise these helpers through the publiccastAPI and are unchanged.cargo test -p arrow-cast --lib: 379 passed, 0 failedcargo clippy -p arrow-cast --all-targets --all-features -- -D warnings: cleancargo fmt --all -- --check: cleancargo doc -p arrow-cast --no-deps: none of the three helper names appear in the generated docs, confirming nothing new is exportedAre there any user-facing changes?
No. The three functions were private before and remain crate-private;
structsis a private module and the glob import is notpub use.AI usage disclosure
Per CONTRIBUTING.md: the extraction was performed with Claude Code assistance. The moved code is the existing upstream code, not generated. AI was used to locate the helper group, perform the mechanical move, and run the verification above. I reviewed the full diff and the verification output before opening this.