diff --git a/cpp/src/reshape/byte_cast.cu b/cpp/src/reshape/byte_cast.cu index 302d99502173..97c5892cce7d 100644 --- a/cpp/src/reshape/byte_cast.cu +++ b/cpp/src/reshape/byte_cast.cu @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -121,7 +122,7 @@ struct byte_list_conversion_fn(std::numeric_limits::max()), + CUDF_EXPECTS(num_chars < static_cast(std::numeric_limits::max()), "Cannot convert strings column to lists column due to size_type limit", std::overflow_error); @@ -130,12 +131,16 @@ struct byte_list_conversion_fn( output_type, num_chars, std::move(*(col_content.data)), rmm::device_buffer{}, 0); - auto result = make_lists_column( - input.size(), - std::move(col_content.children[cudf::strings_column_view::offsets_column_index]), - std::move(uint8_col), - input.null_count(), - detail::copy_bitmask(input, stream, mr)); + auto offsets_col = std::move(col_content.children[strings_column_view::offsets_column_index]); + if (offsets_col->type().id() != type_id::INT32) { + offsets_col = cudf::detail::cast(offsets_col->view(), data_type{type_id::INT32}, stream, mr); + } + + auto result = make_lists_column(input.size(), + std::move(offsets_col), + std::move(uint8_col), + input.null_count(), + detail::copy_bitmask(input, stream, mr)); // If any nulls are present, the corresponding lists must be purged so that // the result is sanitized.