Skip to content

Split arrow_cast::cast struct helpers into their own submodule - #11074

Merged
Jefffrey merged 2 commits into
apache:mainfrom
amitvijapur:refactor/cast-extract-struct-helpers
Sep 17, 2026
Merged

Jefffrey merged 2 commits into
apache:mainfrom
amitvijapur:refactor/cast-extract-struct-helpers

Conversation

@amitvijapur

Copy link
Copy Markdown
Contributor

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.rs is 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 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.

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.
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-cast labels Sep 13, 2026
@amitvijapur

Copy link
Copy Markdown
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 action_required). When a committer has a moment, could someone approve the CI run? Nothing else is outstanding on my side.

@sdf-jkl

sdf-jkl commented Sep 15, 2026

Copy link
Copy Markdown
Member

Thanks @amitvijapur, I saw that. I was hoping to wait on #11097 to avoid burning compute on MIRI

@Jefffrey Jefffrey added the development-process Related to development process of arrow-rs label Sep 17, 2026
@Jefffrey

Copy link
Copy Markdown
Contributor

Thanks @amitvijapur, I saw that. I was hoping to wait on #11097 to avoid burning compute on MIRI

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 👍

@Jefffrey
Jefffrey merged commit f397a4b into apache:main Sep 17, 2026
41 checks passed
@Jefffrey

Copy link
Copy Markdown
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>
@amitvijapur
amitvijapur deleted the refactor/cast-extract-struct-helpers branch September 20, 2026 20:30
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>
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 development-process Related to development process of arrow-rs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants