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

Add grouped_rolling test with STRUCT groupby keys. #9228

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Changes from 1 commit
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
36 changes: 36 additions & 0 deletions cpp/tests/rolling/grouped_rolling_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/iterator_utilities.hpp>
#include <cudf_test/type_lists.hpp>

#include <cudf/aggregation.hpp>
Expand Down Expand Up @@ -2413,3 +2414,38 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingAndFollowingWindowMultiGr
fixed_width_column_wrapper<cudf::size_type>{
{3, 3, 3, 3, 3, 4, 4, 4, 4, 4}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}});
}

TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingAndFollowingStructGroup)
{
// Test that grouping on STRUCT keys produces is possible.

using namespace cudf;
using namespace cudf::test;
mythrocks marked this conversation as resolved.
Show resolved Hide resolved
using T = TypeParam;
using numerics = fixed_width_column_wrapper<T>;

auto const grp_col = [] {
auto grp_col_inner = numerics{0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
return structs_column_wrapper{{grp_col_inner}};
}();

// clang-format off
auto const agg_col = numerics{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
{0, 1, 1, 0, 1, 0, 1, 1, 1, 1}};
// clang-format on

auto const grouping_keys = table_view{{grp_col}};
auto const unbounded_preceding = cudf::window_bounds::unbounded();
auto const unbounded_following = cudf::window_bounds::unbounded();
auto const min_periods = 1L;
auto const output =
cudf::grouped_rolling_window(grouping_keys,
agg_col,
unbounded_preceding,
unbounded_following,
min_periods,
*cudf::make_count_aggregation<cudf::rolling_aggregation>());

CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(),
numerics{{3, 3, 3, 3, 3, 4, 4, 4, 4, 4}, iterators::no_nulls()});
}