Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UnionArray logical_nulls tests #6781

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

gstvg
Copy link
Contributor

@gstvg gstvg commented Nov 23, 2024

Which issue does this PR close?

Follow-up on #6303

Rationale for this change

As noted by @wiedld on #6303 (comment), the existing tests coverage is quite fragile relative to the target architecture and enabled CPU features, leaving most logic untested on ARM, for example.

What changes are included in this PR?

Instead of calling only the public Array::logical_nulls, tests of specific strategies also calls the correspondent private method directly. To do so, part of logical_nulls method, which builds the arguments to be passed to specific implementations, is made into a new private method UnionArray::fields_logical_nulls, and then used by both logical_nulls and the tests.

Are there any user-facing changes?

No, just tests

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 23, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @gstvg

assert_eq!(expected, array.logical_nulls().unwrap().into_inner());
assert_eq!(
expected,
array.mask_sparse_all_with_nulls_skip_one(array.fields_logical_nulls())
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this mask_sparse_all_with_nulls_skip_one function? This formulation is somewhat confusing to me (without delving deeply into the code). Is there any way to make this more "obvious" 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Each strategy for computing the logical_nulls are outlined here. The code determines a cost estimate to decide which strategy to use. Then it calls a helper function per each strategy => and that did the computation.

With the way the tests were written before, it always got the same cost estimate on certain architecture. For example, tests running on ARM would always get the same cost estimate and therefore always pick the same strategy (UnionArray::gather_nulls helper function). So even though this test is named test_sparse_union_logical_nulls_mask_all_nulls_skip_one, it was not actually testing that strategy and helper function.

With this change, the tests are directly calling each helper function.

In the example above, the test named test_sparse_union_logical_nulls_mask_all_nulls_skip_one has been changed to directly calling the helper method UnionArray::mask_sparse_all_with_nulls_skip_one.

@wiedld
Copy link
Contributor

wiedld commented Dec 4, 2024

Just came back from FTO. I'll pick up this review tmrw. Thanks @gstvg !

Copy link
Contributor

@wiedld wiedld left a comment

Choose a reason for hiding this comment

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

Very nice. ❤️

The possible strategies are all tested:

I didn't bother doing a branch coverage analysis, since this is already a big gain. Thank you!

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @gstvg and the review @wiedld

@alamb alamb merged commit 63ad87a into apache:main Dec 6, 2024
26 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants