Skip to content

refactor: parameterize core Arrow tests - #12354

Open
Phoenix500526 wants to merge 7 commits into
apache:mainfrom
Phoenix500526:issue/12328-I
Open

Phoenix500526 wants to merge 7 commits into
apache:mainfrom
Phoenix500526:issue/12328-I

Conversation

@Phoenix500526

@Phoenix500526 Phoenix500526 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #12328.

Rationale for this change

Nested loops and repeated setup make individual test scenarios harder to identify and run separately. This batch uses rstest for selected tests in arrow-array, arrow-buffer, arrow-data, and arrow-schema, retaining short loops where they remain easier to read.

What changes are included in this PR?

  • Array: parameterize Union construction, validity, and slicing tests; separate successful construction from invalid inputs; parameterize Decimal types/scales, FFI byte-array types, and fixed-offset timezones. Keep the two fixed Decimal error-message scenarios separate.
  • Buffer: consolidate repeated-slice tests into six named cases covering i32, u8, and u16 inputs with single-element and multi-element slices.
  • Data: share RunEndEncoded test construction across run-end types; parameterize extension, null extension, and run-end overflow tests, keeping length-conversion overflow separate. Parameterize null-array checks for four View types.
  • Schema: parameterize TimestampWithOffset validation for invalid offset types, nullable fields, and missing/non-UTC timezones, preserving the original panic expectations.
  • Add rstest as a development dependency of these four crates, with default features disabled.

Are these changes tested?

The refactored tests retain the existing inputs and checks, including Decimal precision errors, FFI offsets, timezone inputs, power-of-two repeat boundaries, run-end buffer contents, and overflow errors. Union slicing additionally covers suffix slices and empty slices at the start in both storage modes. All four crates' test suites were verified locally with all features enabled, including unit and documentation tests.

Are there any significant user-facing changes?

No. This changes tests, test helpers, and development dependencies only.

AI usage disclosure

I worked through the test groups individually with Codex, deciding which refactors were worthwhile and how to structure the cases. I wrote and revised parts of the implementation, reviewed the proposed changes, and checked the inputs, assertions, and parameter combinations against the original tests.

Codex helped identify candidates, draft and revise parts of the refactoring, cross-check coverage, run validation commands, and prepare the PR description.

@boring-cyborg boring-cyborg Bot added the arrow-core Core crates related to representing arrow data label Nov 20, 2026
@Phoenix500526 Phoenix500526 changed the title refactor(arrow-array): use rstest for test cases refactor: use rstest in arrow-array and arrow-buffer Nov 20, 2026
@Phoenix500526 Phoenix500526 changed the title refactor: use rstest in arrow-array and arrow-buffer refactor: parameterize array and buffer tests Nov 20, 2026
@Phoenix500526
Phoenix500526 force-pushed the issue/12328-I branch 2 times, most recently from f676f91 to 5b52ff3 Compare November 20, 2026 11:58
@Phoenix500526 Phoenix500526 changed the title refactor: parameterize array and buffer tests refactor: parameterize core Arrow tests Nov 20, 2026
@Phoenix500526
Phoenix500526 marked this pull request as ready for review November 23, 2026 07:29
@Phoenix500526

Copy link
Copy Markdown
Contributor Author

Hi @Jefffrey , this PR is ready for review now. Could you take a look when you have time? CC @Rich-T-kid in case you're interested.

) where
T::Native: From<i32>,
{
let _ = decimal_type;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this decimal_type parameter an unfortunate sideeffect of trying to have a generic typed parameter in rstest? is it not possible to name as _decimal_type to avoid this binding to satisfy linting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the parameter is only used to infer T. I previously tried _decimal_type, but rstest’s generated wrapper uses that binding, which triggers clippy::used_underscore_binding.

Comment thread arrow-data/Cargo.toml Resolved
Comment thread arrow-array/src/ffi.rs Resolved
use std::sync::Arc;

fn create_run_array_data(run_ends: Vec<i32>, values: ArrayData) -> ArrayData {
fn create_run_array_data<T: ArrowNativeType>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably make it generic over ArrowPrimitiveType + RunEndIndexType instead, something like

    fn create_run_array_data<T: ArrowPrimitiveType + RunEndIndexType>(
       run_ends: Vec<T::Native>,
        values: ArrayData,
        run_end_type: DataType,
    ) -> ArrayData {
        let run_ends_field = Arc::new(Field::new(
            Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME,
            T::DATA_TYPE,
            false,
        ));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, updated. Since ArrowPrimitiveType is a supertrait of RunEndIndexType, the RunEndIndexType bound alone is sufficient.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this seems to introduce a circular dependency? i think we should avoid it in that case 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. I noticed the dependency cycle when making the change, but initially proceeded because arrow-array depends on arrow-data normally, while the reverse dependency is dev-only. Cargo can build arrow-data, then arrow-array, and finally the arrow-data tests, so there is no cycle between the build artifacts. But, the Cargo documentation recommends avoiding these cycles where possible. I agree that introducing one just for this test helper isn't worthwhile, so I've removed the dev-dependency and restored the native integer generic with an explicit DataType parameter.

@Jefffrey Jefffrey added the development-process Internal changes; PRs with this label are excluded from changelog label Nov 24, 2026
Give union validation and slicing scenarios independent test results
while preserving existing assertions and adding slice boundaries.

Refs apache#12328
Make decimal, FFI and timezone cases independently runnable while
preserving their existing inputs and assertions.

Refs apache#12328
Share repeat-slice checks across element types and input lengths
while preserving the existing inputs and repeat-count boundaries.

Refs apache#12328
Reduce duplicated test logic while preserving type-specific cases
and overflow coverage.

Refs apache#12328
Reduce duplicated timestamp-with-offset validation tests while
preserving the existing invalid inputs and panic expectations.

Refs apache#12328
Centralize test dependencies and expose independent test cases.
Tie run-end storage and metadata to the same Arrow type.

Refs apache#12328
Avoid a dev-dependency cycle with arrow-array while retaining the
parameterized run-end tests and their existing coverage.

Refs apache#12380
Refs apache#12328

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow-core Core crates related to representing arrow data development-process Internal changes; PRs with this label are excluded from changelog

Projects

None yet

2 participants