-
Notifications
You must be signed in to change notification settings - Fork 930
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
Support sorted merges in cudf.polars #18075
Open
Matt711
wants to merge
10
commits into
rapidsai:branch-25.04
Choose a base branch
from
Matt711:fea/polars/support-merge-sorted
base: branch-25.04
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
24c9edb
Support sorted merges in cudf.polars
Matt711 d01f1df
add a test
Matt711 a614ee7
more tests cases
Matt711 0131fb1
copyright
Matt711 9163acb
improve test coverage
Matt711 d8ed9b7
Merge branch 'branch-25.04' into fea/polars/support-merge-sorted
Matt711 cc3b45e
fix merge sorted when key column is sorted in descending order with n…
Matt711 637bc95
simplify a bit
Matt711 8a4619c
remove outdated test
Matt711 c966377
add schema to non_child_args
Matt711 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import polars as pl | ||
|
||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"descending", | ||
[ | ||
pytest.param( | ||
True, | ||
marks=pytest.mark.xfail(reason="polars/issues/21464"), | ||
), | ||
False, | ||
], | ||
) | ||
def test_merge_sorted_without_nulls(descending): | ||
df0 = pl.LazyFrame({"name": ["steve", "elise", "bob"], "age": [42, 44, 18]}).sort( | ||
"age", descending=descending | ||
) | ||
df1 = pl.LazyFrame( | ||
{ | ||
"name": ["anna", "megan", "steve", "thomas"], | ||
"age": [21, 33, 42, 20], | ||
"height": [5, 5, 5, 5], | ||
} | ||
).sort("age", descending=descending) | ||
q = df0.merge_sorted(df1, key="age") | ||
assert_gpu_result_equal(q) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"descending", | ||
[ | ||
pytest.param( | ||
True, | ||
marks=pytest.mark.xfail(reason="polars/issues/21464"), | ||
), | ||
False, | ||
], | ||
) | ||
def test_merge_sorted_with_nulls(descending): | ||
df0 = pl.LazyFrame( | ||
{"name": ["steve", "elise", "bob", "john"], "age": [42, 44, 18, None]} | ||
).sort("age", descending=descending) | ||
df1 = pl.LazyFrame( | ||
{ | ||
"name": ["anna", "megan", "steve", "thomas", "john"], | ||
"age": [21, 33, 42, 20, None], | ||
"height": [5, 5, 5, 5, 5], | ||
} | ||
).sort("age", descending=descending) | ||
q = df0.merge_sorted(df1, key="age") | ||
assert_gpu_result_equal(q) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this defined above as
_non_child
? Can something be reused or simplified here?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.
I think we need both. The
_non_child
arguments are needed to serialization/deserialization, among other things. While the_non_child_args
are used to execute the IR nodes.