Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG FIX: Raise appropriate strings error when concatenating strings column #8290

Merged
merged 6 commits into from
Jun 1, 2021
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: 8 additions & 1 deletion python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -2312,5 +2312,12 @@ def _concat_columns(objs: "MutableSequence[ColumnBase]") -> ColumnBase:
else:
# Filter out inputs that have 0 length, then concatenate.
objs = [o for o in objs if len(o)]
col = libcudf.concat.concat_columns(objs)
try:
col = libcudf.concat.concat_columns(objs)
except RuntimeError as e:
if "concatenated rows exceeds size_type range" in str(e):
raise OverflowError(
"total size of output is too large for a cudf column"
) from e
raise
return col
14 changes: 14 additions & 0 deletions python/cudf/cudf/tests/test_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,17 @@ def test_build_series_from_nullable_pandas_dtype(pd_dtype, expect_dtype):
).to_array()

np.testing.assert_array_equal(expect_mask, got_mask)


def test_concatenate_large_column_strings():
num_strings = 1_000_000
string_scale_f = 100

s_1 = cudf.Series(["very long string " * string_scale_f] * num_strings)
s_2 = cudf.Series(["very long string " * string_scale_f] * num_strings)

with pytest.raises(
OverflowError,
match="total size of output is too large for a cudf column",
):
cudf.concat([s_1, s_2])