-
Notifications
You must be signed in to change notification settings - Fork 914
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/branch-25.02' into remove-lega…
…cy-dataframe
- Loading branch information
Showing
17 changed files
with
146 additions
and
14 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
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
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
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,36 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""Parallel Select Logic.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from cudf_polars.dsl.ir import Select | ||
from cudf_polars.dsl.traversal import traversal | ||
from cudf_polars.experimental.dispatch import lower_ir_node | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import MutableMapping | ||
|
||
from cudf_polars.dsl.ir import IR | ||
from cudf_polars.experimental.base import PartitionInfo | ||
from cudf_polars.experimental.parallel import LowerIRTransformer | ||
|
||
|
||
@lower_ir_node.register(Select) | ||
def _( | ||
ir: Select, rec: LowerIRTransformer | ||
) -> tuple[IR, MutableMapping[IR, PartitionInfo]]: | ||
child, partition_info = rec(ir.children[0]) | ||
pi = partition_info[child] | ||
if pi.count > 1 and not all( | ||
expr.is_pointwise for expr in traversal([e.value for e in ir.exprs]) | ||
): | ||
# TODO: Handle non-pointwise expressions. | ||
raise NotImplementedError( | ||
f"Selection {ir} does not support multiple partitions." | ||
) | ||
new_node = ir.reconstruct([child]) | ||
partition_info[new_node] = pi | ||
return new_node, partition_info |
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,54 @@ | ||
# 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.fixture(scope="module") | ||
def engine(): | ||
return pl.GPUEngine( | ||
raise_on_fail=True, | ||
executor="dask-experimental", | ||
executor_options={"max_rows_per_partition": 3}, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def df(): | ||
return pl.LazyFrame( | ||
{ | ||
"a": [1, 2, 3, 4, 5, 6, 7], | ||
"b": [1, 1, 1, 1, 1, 1, 1], | ||
} | ||
) | ||
|
||
|
||
def test_select(df, engine): | ||
query = df.select( | ||
pl.col("a") + pl.col("b"), (pl.col("a") * 2 + pl.col("b")).alias("d") | ||
) | ||
assert_gpu_result_equal(query, engine=engine) | ||
|
||
|
||
def test_select_reduce_raises(df, engine): | ||
query = df.select( | ||
(pl.col("a") + pl.col("b")).max(), | ||
(pl.col("a") * 2 + pl.col("b")).alias("d").mean(), | ||
) | ||
with pytest.raises( | ||
pl.exceptions.ComputeError, | ||
match="NotImplementedError", | ||
): | ||
assert_gpu_result_equal(query, engine=engine) | ||
|
||
|
||
def test_select_with_cse_no_agg(df, engine): | ||
expr = pl.col("a") + pl.col("a") | ||
query = df.select(expr, (expr * 2).alias("b"), ((expr * 2) + 10).alias("c")) | ||
assert_gpu_result_equal(query, engine=engine) |