Skip to content

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

Open
amitvijapur wants to merge 1 commit into
apache:mainfrom
amitvijapur:refactor/cast-extract-struct-helpers
Open

Split arrow_cast::cast struct helpers into their own submodule#11074
amitvijapur wants to merge 1 commit into
apache:mainfrom
amitvijapur:refactor/cast-extract-struct-helpers

Conversation

@amitvijapur

Copy link
Copy Markdown

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
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