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

Support max on single-level struct in aggregation context #4434

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/supported_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -15141,7 +15141,7 @@ are limited.
<td><b>NS</b></td>
<td><b>NS</b></td>
<td> </td>
<td><b>NS</b></td>
<td><em>PS<br/>UTC is only supported TZ for child TIMESTAMP;<br/>unsupported child types BINARY, CALENDAR, ARRAY, STRUCT, UDT</em></td>
<td><b>NS</b></td>
</tr>
<tr>
Expand All @@ -15162,7 +15162,7 @@ are limited.
<td><b>NS</b></td>
<td><b>NS</b></td>
<td> </td>
<td><b>NS</b></td>
<td><em>PS<br/>UTC is only supported TZ for child TIMESTAMP;<br/>unsupported child types BINARY, CALENDAR, ARRAY, STRUCT, UDT</em></td>
<td><b>NS</b></td>
</tr>
<tr>
Expand All @@ -15184,7 +15184,7 @@ are limited.
<td><b>NS</b></td>
<td><b>NS</b></td>
<td> </td>
<td><b>NS</b></td>
<td><em>PS<br/>UTC is only supported TZ for child TIMESTAMP;<br/>unsupported child types BINARY, CALENDAR, ARRAY, STRUCT, UDT</em></td>
<td><b>NS</b></td>
</tr>
<tr>
Expand All @@ -15205,7 +15205,7 @@ are limited.
<td><b>NS</b></td>
<td><b>NS</b></td>
<td> </td>
<td><b>NS</b></td>
<td><em>PS<br/>UTC is only supported TZ for child TIMESTAMP;<br/>unsupported child types BINARY, CALENDAR, ARRAY, STRUCT, UDT</em></td>
<td><b>NS</b></td>
</tr>
<tr>
Expand All @@ -15227,7 +15227,7 @@ are limited.
<td><b>NS</b></td>
<td><b>NS</b></td>
<td> </td>
<td><b>NS</b></td>
<td><em>PS<br/>UTC is only supported TZ for child TIMESTAMP;<br/>unsupported child types BINARY, CALENDAR, ARRAY, STRUCT, UDT</em></td>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says that it works for window operations too, but I see no tests for window operations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, removed the window support.

<td><b>NS</b></td>
</tr>
<tr>
Expand All @@ -15248,7 +15248,7 @@ are limited.
<td><b>NS</b></td>
<td><b>NS</b></td>
<td> </td>
<td><b>NS</b></td>
<td><em>PS<br/>UTC is only supported TZ for child TIMESTAMP;<br/>unsupported child types BINARY, CALENDAR, ARRAY, STRUCT, UDT</em></td>
<td><b>NS</b></td>
</tr>
<tr>
Expand Down
19 changes: 19 additions & 0 deletions integration_tests/src/main/python/hash_aggregate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,3 +1695,22 @@ def test_groupby_std_variance_partial_replace_fallback(data_gen,
exist_classes=','.join(exist_clz),
non_exist_classes=','.join(non_exist_clz),
conf=local_conf)

@ignore_order
@pytest.mark.parametrize('data_gen', all_gen + [NullGen()], ids=idfn)
def test_max_single_level_struct(data_gen):
df_gen = [
('a', StructGen([
('aa', data_gen),
('ab', data_gen)])),
('b', IntegerGen())]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it likely that b will have repeated data in it? That way the groupings are likely to have more than one thing in them to compare?

('b', RepeatSeqGen(IntegerGen(), length=20))]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, updated.

Copy link
Collaborator Author

@res-life res-life Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suported both Min and Max.
Removed the window support.
Updated test case.
Seems CUDF has a bug: rapidsai/cudf#8974 (comment). After confired, I'll file an issue.

assert_gpu_and_cpu_are_equal_sql(
lambda spark : gen_df(spark, df_gen, length=1024),
"hash_agg_table",
'select b, max(a) from hash_agg_table group by b',
_no_nans_float_conf)
assert_gpu_and_cpu_are_equal_sql(
lambda spark : gen_df(spark, df_gen, length=1024),
"hash_agg_table",
'select max(a) from hash_agg_table',
_no_nans_float_conf)
Original file line number Diff line number Diff line change
Expand Up @@ -2236,9 +2236,13 @@ object GpuOverrides extends Logging {
expr[Max](
"Max aggregate operator",
ExprChecks.fullAgg(
TypeSig.commonCudfTypes + TypeSig.DECIMAL_128_FULL + TypeSig.NULL, TypeSig.orderable,
// Max supports single level struct, e.g.: max(struct(string, string))
(TypeSig.commonCudfTypes + TypeSig.DECIMAL_128_FULL + TypeSig.NULL + TypeSig.STRUCT)
.nested(TypeSig.commonCudfTypes + TypeSig.DECIMAL_128_FULL + TypeSig.NULL),
TypeSig.orderable,
Seq(ParamCheck("input",
(TypeSig.commonCudfTypes + TypeSig.DECIMAL_128_FULL + TypeSig.NULL)
(TypeSig.commonCudfTypes + TypeSig.DECIMAL_128_FULL + TypeSig.NULL + TypeSig.STRUCT)
.nested(TypeSig.commonCudfTypes + TypeSig.DECIMAL_128_FULL + TypeSig.NULL)
.withPsNote(TypeEnum.DOUBLE, nanAggPsNote)
.withPsNote(TypeEnum.FLOAT, nanAggPsNote),
TypeSig.orderable))
Expand Down