diff --git a/cpp/src/column/column_factories.cu b/cpp/src/column/column_factories.cu index bad20d6817c..ad9c5e4d3a0 100644 --- a/cpp/src/column/column_factories.cu +++ b/cpp/src/column/column_factories.cu @@ -20,11 +20,12 @@ #include #include #include -#include +#include #include #include +#include namespace cudf { @@ -57,15 +58,26 @@ std::unique_ptr column_from_scalar_dispatch::operator() const&>(value); + if (!value.is_valid(stream)) { + return make_strings_column( + size, + make_column_from_scalar(numeric_scalar(0), size + 1, stream, mr), + rmm::device_buffer{}, + size, + cudf::detail::create_null_mask(size, mask_state::ALL_NULL, stream, mr)); + } - // fill the column with the scalar - auto output = strings::detail::fill(strings_column_view(sc), 0, size, sv, stream, mr); + auto& ss = static_cast const&>(value); + auto const d_str = ss.value(stream); // no actual data is copied - return output; + // fill the column with the scalar + rmm::device_uvector indices(size, stream); + auto const row_value = + d_str.empty() ? cudf::strings::detail::string_index_pair{"", 0} + : cudf::strings::detail::string_index_pair{d_str.data(), d_str.size_bytes()}; + thrust::uninitialized_fill( + rmm::exec_policy_nosync(stream), indices.begin(), indices.end(), row_value); + return cudf::strings::detail::make_strings_column(indices.begin(), indices.end(), stream, mr); } template <>