From 97a4022b47184c1ff8a91a93f08fba1383478703 Mon Sep 17 00:00:00 2001 From: MithunR Date: Thu, 21 Sep 2023 17:27:29 -0700 Subject: [PATCH] Fix assert failure for range window functions Fixes #13855. This commit fixes an erroneous assert check in range window functions, where the wrong data-type is checked for timestamp order-by columns. For timestamps, it's the duration::rep type that should be checked, when accessing the order by column. This fix allows ROLLING_TEST to complete correctly, in DEBUG mode. --- cpp/src/rolling/grouped_rolling.cu | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cpp/src/rolling/grouped_rolling.cu b/cpp/src/rolling/grouped_rolling.cu index 6e69b5157c2..7ac784bef43 100644 --- a/cpp/src/rolling/grouped_rolling.cu +++ b/cpp/src/rolling/grouped_rolling.cu @@ -357,6 +357,16 @@ template struct device_value_accessor { column_device_view const col; ///< column view of column in device + /// Checks that the type used to access device values matches the rep-type + /// of the order-by column. + struct is_correct_range_rep { + template /// Order-by type. + constexpr bool operator()() const + { + return std::is_same_v>; + } + }; + /** * @brief constructor * @@ -364,8 +374,11 @@ struct device_value_accessor { */ explicit __device__ device_value_accessor(column_device_view const& col_) : col{col_} { - cudf_assert(type_id_matches_device_storage_type(col.type().id()) && - "the data type mismatch"); + // For non-timestamp types, T must match the order-by column's type. + // For timestamp types, T must match the range rep type for the order-by column. + cudf_assert((type_id_matches_device_storage_type(col.type().id()) or + cudf::type_dispatcher(col.type(), is_correct_range_rep{})) && + "data type mismatch when accessing the order-by column"); } /**