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 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: 34 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,36 @@ 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 cudf::test::iterators::no_nulls;
using cudf::test::iterators::nulls_at;
using T = TypeParam;
using numerics = fixed_width_column_wrapper<T>;
using result_t = fixed_width_column_wrapper<cudf::size_type>;

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

auto const agg_col = numerics{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, nulls_at({0, 3, 5})};

auto const grouping_keys = cudf::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(),
result_t{{3, 3, 3, 3, 3, 4, 4, 4, 4, 4}, no_nulls()});
}