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

Pandas UDF: Sort the data before computing the sum. #1810

Merged
merged 1 commit into from
Feb 25, 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
34 changes: 9 additions & 25 deletions integration_tests/src/main/python/udf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,16 @@ def pandas_sum(to_process: pd.Series) -> float:
conf=arrow_udf_conf)


@pytest.mark.skip("https://github.com/NVIDIA/spark-rapids/issues/757")
@ignore_order
@allow_non_gpu('AggregateInPandasExec', 'PythonUDF', 'Alias')
@pytest.mark.parametrize('data_gen', integral_gens, ids=idfn)
def test_group_aggregate_udf(data_gen):
@f.pandas_udf('long')
def pandas_sum(to_process: pd.Series) -> int:
return to_process.sum()
# Sort the values before computing the sum.
# For details please go to
# https://github.com/NVIDIA/spark-rapids/issues/740#issuecomment-784917512
return to_process.sort_values().sum()

assert_gpu_and_cpu_are_equal_collect(
lambda spark : binary_op_df(spark, data_gen)\
Expand Down Expand Up @@ -134,35 +136,17 @@ def pandas_sum(to_process: pd.Series) -> int:
'Lower_Upper']


# It fails periodically only when using LongGen, so split it into
# "test_window_aggregate_udf_long"
# and
# "test_window_aggregate_udf"
# to unblock the basic window functionality test.
@pytest.mark.skip("https://github.com/NVIDIA/spark-rapids/issues/740")
@ignore_order
@pytest.mark.parametrize('data_gen', [long_gen], ids=idfn)
@pytest.mark.parametrize('window', udf_windows, ids=window_ids)
def test_window_aggregate_udf_long(data_gen, window):

@f.pandas_udf('long')
def pandas_sum(to_process: pd.Series) -> int:
return to_process.sum()

assert_gpu_and_cpu_are_equal_collect(
lambda spark: binary_op_df(spark, data_gen).select(
pandas_sum(f.col('b')).over(window)),
conf=arrow_udf_conf)


@ignore_order
@pytest.mark.parametrize('data_gen', [byte_gen, short_gen, int_gen], ids=idfn)
@pytest.mark.parametrize('data_gen', integral_gens, ids=idfn)
@pytest.mark.parametrize('window', udf_windows, ids=window_ids)
def test_window_aggregate_udf(data_gen, window):

@f.pandas_udf('long')
def pandas_sum(to_process: pd.Series) -> int:
return to_process.sum()
# Sort the values before computing the sum.
# For details please go to
# https://github.com/NVIDIA/spark-rapids/issues/740#issuecomment-784917512
return to_process.sort_values().sum()

assert_gpu_and_cpu_are_equal_collect(
lambda spark: binary_op_df(spark, data_gen).select(
Expand Down