-
Notifications
You must be signed in to change notification settings - Fork 608
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
祖弼
committed
May 14, 2024
1 parent
49c6ce3
commit 7591e29
Showing
3 changed files
with
53 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from __future__ import annotations | ||
|
||
import pandas.testing as tm | ||
import pytest | ||
|
||
import ibis | ||
|
||
pytest.importorskip("pyspark") | ||
|
||
|
||
@pytest.fixture | ||
def t(con): | ||
return con.table("basic_table") | ||
|
||
|
||
@pytest.fixture | ||
def df(con): | ||
return con._session.table("basic_table").toPandas() | ||
|
||
|
||
def test_builtin_udf(t, df): | ||
@ibis.udf.scalar.builtin | ||
def repeat(x, n) -> str: ... | ||
|
||
result = t.mutate(repeated=repeat(t.str_col, 2)).execute() | ||
expected = df.assign(repeated=df.str_col * 2) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_illegal_udf_type(t): | ||
with pytest.raises( | ||
NotImplementedError, | ||
match="Only Builtin UDFs and Pandas UDFs are support in the PySpark backend", | ||
): | ||
|
||
@ibis.udf.scalar.python() | ||
def repeat(x, n) -> str: ... | ||
|
||
t.mutate(repeated=repeat(t.str_col, 2)).execute() | ||