-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af8738c
commit fb68803
Showing
2 changed files
with
26 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
import polars as pl | ||
from polars.testing import assert_frame_equal | ||
|
||
|
||
def test_remove_double_sort() -> None: | ||
assert ( | ||
pl.LazyFrame({"a": [1, 2, 3, 3]}).sort("a").sort("a").explain().count("SORT") | ||
== 1 | ||
) | ||
|
||
|
||
def test_double_sort_maintain_order_18558() -> None: | ||
df = pl.DataFrame( | ||
{ | ||
"col1": [1, 2, 2, 4, 5, 6], | ||
"col2": [2, 2, 0, 0, 2, None], | ||
} | ||
) | ||
|
||
lf = df.lazy().sort("col2").sort("col1", maintain_order=True) | ||
|
||
expect = pl.DataFrame( | ||
[ | ||
pl.Series("col1", [1, 2, 2, 4, 5, 6], dtype=pl.Int64), | ||
pl.Series("col2", [2, 0, 2, 0, 2, None], dtype=pl.Int64), | ||
] | ||
) | ||
|
||
assert_frame_equal(lf.collect(), expect) |