Skip to content

Commit

Permalink
Fix assert failure for range window functions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mythrocks committed Sep 22, 2023
1 parent f0ba859 commit 97a4022
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cpp/src/rolling/grouped_rolling.cu
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,28 @@ template <typename T>
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 <typename U> /// Order-by type.
constexpr bool operator()() const
{
return std::is_same_v<T, cudf::detail::range_rep_type<U>>;
}
};

/**
* @brief constructor
*
* @param[in] col_ column device view of cudf column
*/
explicit __device__ device_value_accessor(column_device_view const& col_) : col{col_}
{
cudf_assert(type_id_matches_device_storage_type<T>(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<T>(col.type().id()) or
cudf::type_dispatcher(col.type(), is_correct_range_rep{})) &&
"data type mismatch when accessing the order-by column");
}

/**
Expand Down

0 comments on commit 97a4022

Please sign in to comment.