Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use num_slices to guarantee partition shape in the pandas udf tests #4154

Merged
merged 2 commits into from
Nov 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions integration_tests/src/main/python/udf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@
# itself.
####################################################################


@pytest.mark.parametrize('data_gen', integral_gens, ids=idfn)
def test_pandas_math_udf(data_gen):
def add(a, b):
return a + b
my_udf = f.pandas_udf(add, returnType=LongType())
assert_gpu_and_cpu_are_equal_collect(
lambda spark : binary_op_df(spark, data_gen).select(
lambda spark : binary_op_df(spark, data_gen, num_slices=4).select(
my_udf(f.col('a') - 3, f.col('b'))),
conf=arrow_udf_conf)

Expand All @@ -79,7 +78,7 @@ def iterator_add(to_process: Iterator[Tuple[pd.Series, pd.Series]]) -> Iterator[

my_udf = f.pandas_udf(iterator_add, returnType=LongType())
assert_gpu_and_cpu_are_equal_collect(
lambda spark : binary_op_df(spark, data_gen).select(
lambda spark : binary_op_df(spark, data_gen, num_slices=4).select(
my_udf(f.col('a'), f.col('b'))),
conf=arrow_udf_conf)

Expand All @@ -91,7 +90,7 @@ def nested_size(nested):

my_udf = f.pandas_udf(nested_size, returnType=LongType())
assert_gpu_and_cpu_are_equal_collect(
lambda spark: unary_op_df(spark, data_gen).select(my_udf(f.col('a'))),
lambda spark: unary_op_df(spark, data_gen, num_slices=4).select(my_udf(f.col('a'))),
conf=arrow_udf_conf)


Expand Down Expand Up @@ -252,7 +251,7 @@ def pandas_filter(iterator):
yield data[data.b <= data.a]

assert_gpu_and_cpu_are_equal_collect(
lambda spark : binary_op_df(spark, data_gen)\
lambda spark : binary_op_df(spark, data_gen, num_slices=4)\
.mapInPandas(pandas_filter, schema="a long, b long"),
conf=arrow_udf_conf)

Expand Down Expand Up @@ -290,7 +289,7 @@ def col_types_udf(pdf_itr):
})

assert_gpu_and_cpu_are_equal_collect(
lambda spark: unary_op_df(spark, data_gen)\
lambda spark: unary_op_df(spark, data_gen, num_slices=4)\
.mapInPandas(col_types_udf, schema=udf_out_schema),
conf=arrow_udf_conf)

Expand Down