Repository navigation
refactor: parameterize core Arrow tests - #12354
Phoenix500526 wants to merge 7 commits into
Conversation
f676f91 to
5b52ff3
Compare
|
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. |
5b52ff3 to
6800066
Compare
| ) where | ||
| T::Native: From<i32>, | ||
| { | ||
| let _ = decimal_type; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| use std::sync::Arc; | ||
|
|
||
| fn create_run_array_data(run_ends: Vec<i32>, values: ArrayData) -> ArrayData { | ||
| fn create_run_array_data<T: ArrowNativeType>( |
There was a problem hiding this comment.
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,
));There was a problem hiding this comment.
Good call, updated. Since ArrowPrimitiveType is a supertrait of RunEndIndexType, the RunEndIndexType bound alone is sufficient.
There was a problem hiding this comment.
actually this seems to introduce a circular dependency? i think we should avoid it in that case 🤔
There was a problem hiding this comment.
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.
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
54ca29b to
67d9b3c
Compare
Which issue does this PR close?
Part of #12328.
arrow-array).arrow-buffer).arrow-data).arrow-schema).Rationale for this change
Nested loops and repeated setup make individual test scenarios harder to identify and run separately. This batch uses
rstestfor selected tests inarrow-array,arrow-buffer,arrow-data, andarrow-schema, retaining short loops where they remain easier to read.What changes are included in this PR?
rstestas 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.