-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tests of dataframe scan (#16003)
Also assert that unsupported file scan operations raise. Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - https://github.com/brandon-b-miller URL: #16003
- Loading branch information
Showing
7 changed files
with
150 additions
and
3 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
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.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"subset", | ||
[ | ||
None, | ||
["a", "c"], | ||
["b", "c", "d"], | ||
["b", "d"], | ||
["b", "c"], | ||
["c", "e"], | ||
["d", "e"], | ||
pl.selectors.string(), | ||
pl.selectors.integer(), | ||
], | ||
) | ||
@pytest.mark.parametrize("predicate_pushdown", [False, True]) | ||
def test_scan_drop_nulls(subset, predicate_pushdown): | ||
df = pl.LazyFrame( | ||
{ | ||
"a": [1, 2, 3, 4], | ||
"b": [None, 4, 5, None], | ||
"c": [6, 7, None, None], | ||
"d": [8, None, 9, 10], | ||
"e": [None, None, "A", None], | ||
} | ||
) | ||
# Drop nulls are pushed into filters | ||
q = df.drop_nulls(subset) | ||
|
||
assert_gpu_result_equal( | ||
q, collect_kwargs={"predicate_pushdown": predicate_pushdown} | ||
) |
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,6 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from __future__ import annotations | ||
|
||
__all__: list[str] = [] |
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,35 @@ | ||
# 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.testing.asserts import ( | ||
assert_gpu_result_equal, | ||
assert_ir_translation_raises, | ||
) | ||
|
||
|
||
def test_translation_assert_raises(): | ||
df = pl.LazyFrame({"a": [1, 2, 3]}) | ||
|
||
# This should succeed | ||
assert_gpu_result_equal(df) | ||
|
||
with pytest.raises(AssertionError): | ||
# This should fail, because we can translate this query. | ||
assert_ir_translation_raises(df, NotImplementedError) | ||
|
||
class E(Exception): | ||
pass | ||
|
||
unsupported = df.group_by("a").agg(pl.col("a").cum_max().alias("b")) | ||
# Unsupported query should raise NotImplementedError | ||
assert_ir_translation_raises(unsupported, NotImplementedError) | ||
|
||
with pytest.raises(AssertionError): | ||
# This should fail, because we can't translate this query, but it doesn't raise E. | ||
assert_ir_translation_raises(unsupported, E) |