Skip to content

Commit

Permalink
Add grouped_rolling test with STRUCT groupby keys. (#9228)
Browse files Browse the repository at this point in the history
Fixes #8887.

#9024 added support for `STRUCT` groupby keys.
This commit adds a test for `grouped_rolling_window()` where the groupby keys are `STRUCT`.

Authors:
  - MithunR (https://github.com/mythrocks)

Approvers:
  - Vukasin Milovanovic (https://github.com/vuule)
  - David Wendt (https://github.com/davidwendt)

URL: #9228
  • Loading branch information
mythrocks authored Sep 15, 2021
1 parent 651ec49 commit bb9ed33
Showing 1 changed file with 34 additions and 0 deletions.
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()});
}

0 comments on commit bb9ed33

Please sign in to comment.