Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions cpp/src/strings/slice.cu
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,8 @@ std::unique_ptr<column> slice_strings(strings_column_view const& input,
"Parameter starts must have the same number of rows as strings.");
CUDF_EXPECTS(stops_column.size() == input.size(),
"Parameter stops must have the same number of rows as strings.");
CUDF_EXPECTS(cudf::have_same_types(starts_column, stops_column),
"Parameters starts and stops must be of the same type.",
cudf::data_type_error);
CUDF_EXPECTS(starts_column.null_count() == 0, "Parameter starts must not contain nulls.");
CUDF_EXPECTS(stops_column.null_count() == 0, "Parameter stops must not contain nulls.");
CUDF_EXPECTS(starts_column.type().id() != data_type{type_id::BOOL8}.id(),
"Positions values must not be bool type.",
cudf::data_type_error);
CUDF_EXPECTS(is_fixed_width(starts_column.type()),
"Positions values must be fixed width type.",
cudf::data_type_error);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indexalator-factory function below already checks these are valid index types.


auto starts_iter = cudf::detail::indexalator_factory::make_input_iterator(starts_column);
auto stops_iter = cudf::detail::indexalator_factory::make_input_iterator(stops_column);
Expand Down
14 changes: 13 additions & 1 deletion cpp/tests/strings/slice_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -257,6 +257,18 @@ TEST_F(StringsSliceTest, MaxPositions)
CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected);
}

TEST_F(StringsSliceTest, MixedTypePositions)
{
auto input =
cudf::test::strings_column_wrapper({"a", "bc", "def", "ghij", "klmno", "pqrstu", "éuvwxyz"});
auto sv = cudf::strings_column_view(input);
auto starts = cudf::test::fixed_width_column_wrapper<int16_t>({0, 1, 2, 3, 4, 5, 6});
auto stops = cudf::test::fixed_width_column_wrapper<int64_t>({1, 2, 3, 4, 5, 6, 7});
auto expected = cudf::test::strings_column_wrapper({"a", "c", "f", "j", "o", "u", "z"});
auto results = cudf::strings::slice_strings(sv, starts, stops);
CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected);
}

TEST_F(StringsSliceTest, MultiByteChars)
{
auto input = cudf::test::strings_column_wrapper({
Expand Down