-
Notifications
You must be signed in to change notification settings - Fork 4.2k
GH-46856: [C++][Python] Add binary view comparison kernels #49964
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1722,6 +1722,30 @@ def con(values): | |
| assert result.equals(con([False, True, True, None])) | ||
|
|
||
|
|
||
| def test_equal_binary_view(): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it's useful to add these tests on the Python side, since we're already exercising this in C++ tests.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that makes sense. I thought it would be cleaner to address initial issue by writing python tests covering that. I can remove it, if you think that is redundant.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think it's redundant.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@pitrou removed redundant tests. |
||
| arr = pa.array([b"abc"], pa.binary_view()) | ||
| result = pc.equal(arr, arr) | ||
| assert result.to_pylist() == [True] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize(("typ", "values"), [ | ||
| (pa.binary_view(), [b"", b"abc", b"abcdefghijklmnop", None]), | ||
| (pa.string_view(), ["", "abc", "abcdefghijklmnop", None]), | ||
| ]) | ||
| def test_compare_view_types(typ, values): | ||
| arr = pa.array(values, type=typ) | ||
| other = pa.array(values, type=typ) | ||
| expected_equal = [None if value is None else True for value in values] | ||
| expected_not_equal = [None if value is None else False for value in values] | ||
|
|
||
| assert pc.equal(arr, other).to_pylist() == expected_equal | ||
| assert pc.not_equal(arr, other).to_pylist() == expected_not_equal | ||
| assert pc.less(arr, other).to_pylist() == expected_not_equal | ||
| assert pc.less_equal(arr, other).to_pylist() == expected_equal | ||
| assert pc.greater(arr, other).to_pylist() == expected_not_equal | ||
| assert pc.greater_equal(arr, other).to_pylist() == expected_equal | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("typ", ["array", "chunked_array"]) | ||
| def test_compare_scalar(typ): | ||
| if typ == "array": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CheckScalarBinaryalready checks sliced inputs, this test is not necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed redundant test.