From f5366e51cef9f8934086c3ddbae7146ffe98266e Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Fri, 13 Dec 2024 11:04:33 +0000 Subject: [PATCH] Deprecate cudf::grouped_time_range_rolling_window Since the range-based rolling window APIs were extended to support any orderable column (rather than just time-based windows), this function has been a thin forwarding wrapper to cudf::grouped_range_rolling_window. It could have been deprecated at the time, but was not. It seems there are no usages outside of the libcudf test suite. Partially addresses #13050. --- cpp/include/cudf/rolling.hpp | 11 +- cpp/tests/rolling/collect_ops_test.cpp | 226 ++--- cpp/tests/rolling/grouped_rolling_test.cpp | 948 +++++++++++---------- cpp/tests/streams/rolling_test.cpp | 25 +- 4 files changed, 645 insertions(+), 565 deletions(-) diff --git a/cpp/include/cudf/rolling.hpp b/cpp/include/cudf/rolling.hpp index 8a717c3f510..81562ba6248 100644 --- a/cpp/include/cudf/rolling.hpp +++ b/cpp/include/cudf/rolling.hpp @@ -16,6 +16,7 @@ #pragma once +#include #include #include #include @@ -322,6 +323,8 @@ std::unique_ptr grouped_rolling_window( * @brief Applies a grouping-aware, timestamp-based rolling window function to the values in a * column. * + * @deprecated Since 25.02, to be removed in 25.04 + * * Like `rolling_window()`, this function aggregates values in a window around each * element of a specified `input` column. It differs from `rolling_window()` in two respects: * 1. The elements of the `input` column are grouped into distinct groups (e.g. the result of a @@ -403,7 +406,8 @@ std::unique_ptr grouped_rolling_window( * * @returns A nullable output column containing the rolling window results */ -std::unique_ptr grouped_time_range_rolling_window( +[[deprecated("Use cudf::grouped_range_rolling_window instead")]] std::unique_ptr +grouped_time_range_rolling_window( table_view const& group_keys, column_view const& timestamp_column, cudf::order const& timestamp_order, @@ -419,6 +423,8 @@ std::unique_ptr grouped_time_range_rolling_window( * @brief Applies a grouping-aware, timestamp-based rolling window function to the values in a * column,. * + * @deprecated Since 25.02, to be removed in 25.04 + * * @details @copydetails grouped_time_range_rolling_window( * table_view const& group_keys, * column_view const& timestamp_column, @@ -434,7 +440,8 @@ std::unique_ptr grouped_time_range_rolling_window( * The `preceding_window_in_days` and `following_window_in_days` are specified as a `window_bounds` * and supports "unbounded" windows, if set to `window_bounds::unbounded()`. */ -std::unique_ptr grouped_time_range_rolling_window( +[[deprecated("Use cudf::grouped_range_rolling_window instead")]] std::unique_ptr +grouped_time_range_rolling_window( table_view const& group_keys, column_view const& timestamp_column, cudf::order const& timestamp_order, diff --git a/cpp/tests/rolling/collect_ops_test.cpp b/cpp/tests/rolling/collect_ops_test.cpp index e8a36d9ab48..b784b1f008d 100644 --- a/cpp/tests/rolling/collect_ops_test.cpp +++ b/cpp/tests/rolling/collect_ops_test.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -673,16 +674,16 @@ TYPED_TEST(TypedCollectListTest, BasicGroupedTimeRangeRollingWindow) cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::fixed_width_column_wrapper{10, 11, 12, 13, 14, 20, 21, 22, 23}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 1; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -699,13 +700,13 @@ TYPED_TEST(TypedCollectListTest, BasicGroupedTimeRangeRollingWindow) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -723,16 +724,16 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowWithNulls) cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::fixed_width_column_wrapper{ {10, 11, 12, 13, 14, 20, 21, 22, 23}, {1, 0, 1, 1, 1, 1, 0, 1, 1}}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 1; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -753,13 +754,13 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowWithNulls) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -788,16 +789,16 @@ TEST_F(CollectListTest, BasicGroupedTimeRangeRollingWindowOnStrings) cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::strings_column_wrapper{"10", "11", "12", "13", "14", "20", "21", "22", "23"}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 1; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -814,13 +815,13 @@ TEST_F(CollectListTest, BasicGroupedTimeRangeRollingWindowOnStrings) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -837,16 +838,16 @@ TEST_F(CollectListTest, GroupedTimeRangeRollingWindowOnStringsWithNulls) auto const input_column = cudf::test::strings_column_wrapper{{"10", "11", "12", "13", "14", "20", "21", "22", "23"}, {true, false, true, true, true, true, false, true, true}}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 1; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -868,13 +869,13 @@ TEST_F(CollectListTest, GroupedTimeRangeRollingWindowOnStringsWithNulls) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -912,16 +913,16 @@ TYPED_TEST(TypedCollectListTest, BasicGroupedTimeRangeRollingWindowOnStructs) struct_members.emplace_back(numeric_member_column.release()); struct_members.emplace_back(string_member_column.release()); auto const struct_column = cudf::make_structs_column(9, std::move(struct_members), 0, {}); - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 1; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, struct_column->view(), - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -947,13 +948,13 @@ TYPED_TEST(TypedCollectListTest, BasicGroupedTimeRangeRollingWindowOnStructs) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, struct_column->view(), - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -973,16 +974,16 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowWithMinPeriods) cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::fixed_width_column_wrapper{10, 11, 12, 13, 14, 20, 21, 22, 23}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 4; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -1002,13 +1003,13 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowWithMinPeriods) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -1028,16 +1029,16 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowWithNullsAndMinPer cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::fixed_width_column_wrapper{ {10, 11, 12, 13, 14, 20, 21, 22, 23}, {1, 0, 1, 1, 1, 1, 0, 1, 1}}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 4; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -1060,13 +1061,13 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowWithNullsAndMinPer CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -1099,16 +1100,16 @@ TEST_F(CollectListTest, GroupedTimeRangeRollingWindowOnStringsWithMinPeriods) cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::strings_column_wrapper{"10", "11", "12", "13", "14", "20", "21", "22", "23"}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 4; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -1128,13 +1129,13 @@ TEST_F(CollectListTest, GroupedTimeRangeRollingWindowOnStringsWithMinPeriods) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -1153,16 +1154,16 @@ TEST_F(CollectListTest, GroupedTimeRangeRollingWindowOnStringsWithNullsAndMinPer auto const input_column = cudf::test::strings_column_wrapper{{"10", "11", "12", "13", "14", "20", "21", "22", "23"}, {true, false, true, true, true, true, false, true, true}}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 4; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -1185,13 +1186,13 @@ TEST_F(CollectListTest, GroupedTimeRangeRollingWindowOnStringsWithNullsAndMinPer CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -1233,16 +1234,16 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowOnStructsWithMinPe struct_members.emplace_back(numeric_member_column.release()); struct_members.emplace_back(string_member_column.release()); auto const struct_column = cudf::make_structs_column(9, std::move(struct_members), 0, {}); - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 4; - auto const result = cudf::grouped_time_range_rolling_window( + auto const result = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, struct_column->view(), - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation()); @@ -1274,13 +1275,13 @@ TYPED_TEST(TypedCollectListTest, GroupedTimeRangeRollingWindowOnStructsWithMinPe CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = cudf::grouped_time_range_rolling_window( + auto const result_with_nulls_excluded = cudf::grouped_range_rolling_window( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, struct_column->view(), - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE)); @@ -1322,24 +1323,23 @@ auto grouped_rolling_collect_set(cudf::table_view const& group_keys, cudf::lists_column_view{result->view()}, cudf::order::ASCENDING, cudf::null_order::AFTER); } -template -auto grouped_time_range_rolling_collect_set(cudf::table_view const& group_keys, - cudf::column_view const& timestamp_column, - cudf::order const& timestamp_order, - cudf::column_view const& input, - WindowType const& preceding_window_in_days, - WindowType const& following_window_in_days, - cudf::size_type min_periods, - cudf::rolling_aggregation const& agg) +auto grouped_range_rolling_collect_set(cudf::table_view const& group_keys, + cudf::column_view const& timestamp_column, + cudf::order const& timestamp_order, + cudf::column_view const& input, + cudf::range_window_bounds const& preceding_window_in_days, + cudf::range_window_bounds const& following_window_in_days, + cudf::size_type min_periods, + cudf::rolling_aggregation const& agg) { - auto const result = cudf::grouped_time_range_rolling_window(group_keys, - timestamp_column, - timestamp_order, - input, - preceding_window_in_days, - following_window_in_days, - min_periods, - agg); + auto const result = cudf::grouped_range_rolling_window(group_keys, + timestamp_column, + timestamp_order, + input, + preceding_window_in_days, + following_window_in_days, + min_periods, + agg); EXPECT_EQ(result->type().id(), cudf::type_id::LIST); return cudf::lists::sort_lists( @@ -1874,16 +1874,16 @@ TYPED_TEST(TypedCollectSetTest, BasicGroupedTimeRangeRollingWindow) cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::fixed_width_column_wrapper{10, 11, 12, 13, 14, 20, 21, 22, 23}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 1; - auto const result = grouped_time_range_rolling_collect_set( + auto const result = grouped_range_rolling_collect_set( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_set_aggregation()); @@ -1900,13 +1900,13 @@ TYPED_TEST(TypedCollectSetTest, BasicGroupedTimeRangeRollingWindow) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = grouped_time_range_rolling_collect_set( + auto const result_with_nulls_excluded = grouped_range_rolling_collect_set( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_set_aggregation(cudf::null_policy::EXCLUDE)); @@ -1924,16 +1924,16 @@ TYPED_TEST(TypedCollectSetTest, GroupedTimeRangeRollingWindowWithNulls) cudf::test::fixed_width_column_wrapper{1, 1, 1, 1, 1, 2, 2, 2, 2}; auto const input_column = cudf::test::fixed_width_column_wrapper{ {10, 10, 12, 13, 14, 20, 21, 22, 22}, {1, 0, 1, 1, 1, 1, 0, 1, 1}}; - auto const preceding = 2; - auto const following = 1; + auto const preceding = cudf::duration_scalar(2, true); + auto const following = cudf::duration_scalar(1, true); auto const min_periods = 1; - auto const result = grouped_time_range_rolling_collect_set( + auto const result = grouped_range_rolling_collect_set( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_set_aggregation()); @@ -1955,13 +1955,13 @@ TYPED_TEST(TypedCollectSetTest, GroupedTimeRangeRollingWindowWithNulls) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_result->view(), result->view()); - auto const result_with_nulls_excluded = grouped_time_range_rolling_collect_set( + auto const result_with_nulls_excluded = grouped_range_rolling_collect_set( cudf::table_view{std::vector{group_column}}, time_column, cudf::order::ASCENDING, input_column, - preceding, - following, + cudf::range_window_bounds::get(preceding), + cudf::range_window_bounds::get(following), min_periods, *cudf::make_collect_set_aggregation(cudf::null_policy::EXCLUDE)); diff --git a/cpp/tests/rolling/grouped_rolling_test.cpp b/cpp/tests/rolling/grouped_rolling_test.cpp index 78b444bcd93..6e7c0439922 100644 --- a/cpp/tests/rolling/grouped_rolling_test.cpp +++ b/cpp/tests/rolling/grouped_rolling_test.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -708,14 +709,13 @@ class GroupedTimeRangeRollingTest : public cudf::test::BaseFixture { std::unique_ptr output; // wrap windows - EXPECT_NO_THROW(output = cudf::grouped_time_range_rolling_window(keys, - timestamp_column, - timestamp_order, - input, - preceding_window_in_days, - following_window_in_days, - min_periods, - op)); + auto preceding = cudf::range_window_bounds::get( + cudf::duration_scalar(preceding_window_in_days, true)); + auto following = cudf::range_window_bounds::get( + cudf::duration_scalar(following_window_in_days, true)); + EXPECT_NO_THROW( + output = cudf::grouped_range_rolling_window( + keys, timestamp_column, timestamp_order, input, preceding, following, min_periods, op)); auto reference = create_reference_output(op, timestamp_column, @@ -1275,18 +1275,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountSingleGroupTimestampASCNu {false, false, false, false, true, true, true, true, true, true}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1307,18 +1309,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountSingleGroupTimestampASCNu {true, true, true, true, true, true, false, false, false, false}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1337,18 +1341,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountMultiGroupTimestampASCNul {false, false, false, true, true, false, false, true, true, true}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1367,18 +1373,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountMultiGroupTimestampASCNul {true, true, true, false, false, true, true, true, false, false}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1398,18 +1406,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountSingleGroupTimestampDESCN {false, false, false, false, true, true, true, true, true, true}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1430,18 +1440,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountSingleGroupTimestampDESCN {true, true, true, true, true, true, false, false, false, false}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1460,18 +1472,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountMultiGroupTimestampDESCNu {false, false, false, true, true, false, false, true, true, true}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1490,18 +1504,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountMultiGroupTimestampDESCNu {true, true, true, false, false, true, true, true, false, false}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1522,18 +1538,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountSingleGroupAllNullTimesta {false, false, false, false, false, false, false, false, false, false}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1554,18 +1572,20 @@ TYPED_TEST(TypedNullTimestampTestForRangeQueries, CountMultiGroupAllNullTimestam {true, true, true, true, true, false, false, false, false, false}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - preceding, - following, - min_periods, - *cudf::make_count_aggregation()); + auto const preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + preceding, + following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1596,19 +1616,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingWindowSingleGroupTimestam {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {false, false, false, false, true, true, true, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1627,19 +1649,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingWindowSingleGroupTimestam {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {false, false, false, false, true, true, true, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1659,19 +1683,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {false, false, false, false, true, true, true, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), @@ -1690,19 +1716,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingWindowSingleGroupTimestam {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {true, true, true, true, true, true, false, false, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1721,19 +1749,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingWindowSingleGroupTimestam {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {true, true, true, true, true, true, false, false, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1753,19 +1783,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {true, true, true, true, true, true, false, false, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), @@ -1784,19 +1816,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingWindowSingleGroupTimestam {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {false, false, false, false, true, true, true, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1815,19 +1849,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingWindowSingleGroupTimestam {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {false, false, false, false, true, true, true, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1847,19 +1883,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {false, false, false, false, true, true, true, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), @@ -1878,19 +1916,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingWindowSingleGroupTimestam {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {true, true, true, true, true, true, false, false, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1909,19 +1949,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingWindowSingleGroupTimestam {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {true, true, true, true, true, true, false, false, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -1941,19 +1983,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {true, true, true, true, true, true, false, false, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), @@ -1971,19 +2015,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingCountMultiGroupTimestampA {1, 2, 2, 1, 2, 1, 2, 3, 4, 5}, {false, false, false, true, true, false, false, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2001,19 +2047,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingCountMultiGroupTimestampA {1, 2, 2, 1, 2, 1, 2, 3, 4, 5}, {false, false, false, true, true, false, false, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2032,19 +2080,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {1, 2, 2, 1, 2, 1, 2, 3, 4, 5}, {false, false, false, true, true, false, false, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), @@ -2062,19 +2112,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingCountMultiGroupTimestampA {1, 2, 2, 1, 3, 1, 2, 3, 4, 5}, {true, true, true, false, false, true, true, true, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2092,19 +2144,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingCountMultiGroupTimestampA {1, 2, 2, 1, 3, 1, 2, 3, 4, 5}, {true, true, true, false, false, true, true, true, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2123,19 +2177,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {1, 2, 2, 1, 3, 1, 2, 3, 4, 5}, {true, true, true, false, false, true, true, true, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::ASCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::ASCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), @@ -2153,19 +2209,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingCountMultiGroupTimestampD {4, 3, 2, 1, 0, 9, 8, 7, 6, 5}, {false, false, false, true, true, false, false, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2183,19 +2241,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingCountMultiGroupTimestampD {4, 3, 2, 1, 0, 9, 8, 7, 6, 5}, {false, false, false, true, true, false, false, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2214,19 +2274,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {4, 3, 2, 1, 0, 9, 8, 7, 6, 5}, {false, false, false, true, true, false, false, true, true, true}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), @@ -2244,19 +2306,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedPrecedingCountMultiGroupTimestampD {4, 3, 2, 1, 0, 9, 8, 7, 6, 5}, {true, true, true, false, false, true, true, true, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const one_day_following = cudf::window_bounds::get(1L); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - one_day_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const one_day_following = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + one_day_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2274,19 +2338,21 @@ TYPED_TEST(TypedUnboundedWindowTest, UnboundedFollowingCountMultiGroupTimestampD {4, 3, 2, 1, 0, 9, 8, 7, 6, 5}, {true, true, true, false, false, true, true, true, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const one_day_preceding = cudf::window_bounds::get(1L); - auto const unbounded_following = cudf::window_bounds::unbounded(); - auto const min_periods = 1L; - auto const output = cudf::grouped_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - one_day_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const one_day_preceding = + cudf::range_window_bounds::get(cudf::duration_scalar(1L, true)); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + one_day_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(output->view(), cudf::test::fixed_width_column_wrapper{ @@ -2305,19 +2371,21 @@ TYPED_TEST(TypedUnboundedWindowTest, {4, 3, 2, 1, 0, 9, 8, 7, 6, 5}, {true, true, true, false, false, true, true, true, false, false}}; - auto const grouping_keys = cudf::table_view{std::vector{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_time_range_rolling_window( - grouping_keys, - time_col, - cudf::order::DESCENDING, - agg_col, - unbounded_preceding, - unbounded_following, - min_periods, - *cudf::make_count_aggregation()); + auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; + auto const unbounded_preceding = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const unbounded_following = + cudf::range_window_bounds::unbounded(cudf::data_type(cudf::type_to_id())); + auto const min_periods = 1L; + auto const output = + cudf::grouped_range_rolling_window(grouping_keys, + time_col, + cudf::order::DESCENDING, + agg_col, + unbounded_preceding, + unbounded_following, + min_periods, + *cudf::make_count_aggregation()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( output->view(), diff --git a/cpp/tests/streams/rolling_test.cpp b/cpp/tests/streams/rolling_test.cpp index 4d9899870b4..50411c1a32a 100644 --- a/cpp/tests/streams/rolling_test.cpp +++ b/cpp/tests/streams/rolling_test.cpp @@ -20,6 +20,7 @@ #include #include +#include #include class RollingTest : public cudf::test::BaseFixture {}; @@ -167,16 +168,18 @@ TEST_F(GroupedTimeRollingTest, FixedSize) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {0, 0, 0, 0, 1, 1, 1, 1, 1, 1}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const preceding = 1L; - auto const following = 1L; - auto const min_periods = 1L; - cudf::grouped_time_range_rolling_window( + auto const preceding = + cudf::duration_scalar(1L, true, cudf::test::get_default_stream()); + auto const following = + cudf::duration_scalar(1L, true, cudf::test::get_default_stream()); + auto const min_periods = 1L; + cudf::grouped_range_rolling_window( grouping_keys, time_col, cudf::order::ASCENDING, agg_col, - preceding, - following, + cudf::range_window_bounds::get(preceding, cudf::test::get_default_stream()), + cudf::range_window_bounds::get(following, cudf::test::get_default_stream()), min_periods, *cudf::make_count_aggregation(), cudf::test::get_default_stream()); @@ -193,17 +196,19 @@ TEST_F(GroupedTimeRollingTest, WindowBounds) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {0, 0, 0, 0, 1, 1, 1, 1, 1, 1}}; auto const grouping_keys = cudf::table_view{std::vector{grp_col}}; - auto const unbounded_preceding = cudf::window_bounds::unbounded(); - auto const following = cudf::window_bounds::get(1L); + auto const unbounded_preceding = cudf::range_window_bounds::unbounded( + cudf::data_type(cudf::type_to_id()), cudf::test::get_default_stream()); + auto const following = + cudf::duration_scalar(1L, true, cudf::test::get_default_stream()); auto const min_periods = 1L; - cudf::grouped_time_range_rolling_window( + cudf::grouped_range_rolling_window( grouping_keys, time_col, cudf::order::ASCENDING, agg_col, unbounded_preceding, - following, + cudf::range_window_bounds::get(following, cudf::test::get_default_stream()), min_periods, *cudf::make_count_aggregation(), cudf::test::get_default_stream());