-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove mapfunction nodes that don't exist/aren't supported
We can't correctly implemented merge_sorted to match polars because libcudf's implementation is not stable wrt input order. drop_nulls is no longer implemented as a MapFunction, but instead a boolean filter. Finally, add coverage of the mapfunctions we do handle.
- Loading branch information
Showing
2 changed files
with
57 additions
and
41 deletions.
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import polars as pl | ||
|
||
from cudf_polars import translate_ir | ||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
def test_merge_sorted_raises(): | ||
df1 = pl.LazyFrame({"a": [1, 6, 9], "b": [1, -10, 4]}) | ||
df2 = pl.LazyFrame({"a": [-1, 5, 11, 20], "b": [2, 7, -4, None]}) | ||
df3 = pl.LazyFrame({"a": [-10, 20, 21], "b": [1, 2, 3]}) | ||
|
||
q = df1.merge_sorted(df2, key="a").merge_sorted(df3, key="a") | ||
|
||
with pytest.raises(NotImplementedError): | ||
_ = translate_ir(q._ldf.visit()) | ||
|
||
|
||
def test_explode_multiple_raises(): | ||
df = pl.LazyFrame({"a": [[1, 2], [3, 4]], "b": [[5, 6], [7, 8]]}) | ||
q = df.explode("a", "b") | ||
|
||
with pytest.raises(NotImplementedError): | ||
_ = translate_ir(q._ldf.visit()) | ||
|
||
|
||
@pytest.mark.parametrize("column", ["a", "b"]) | ||
def test_explode_single(column): | ||
df = pl.LazyFrame( | ||
{ | ||
"a": [[1, 2], [3, 4], None], | ||
"b": [[5, 6], [7, 8], [9, 10]], | ||
"c": [None, 11, 12], | ||
} | ||
) | ||
q = df.explode(column) | ||
|
||
assert_gpu_result_equal(q) |