diff --git a/python/cudf/cudf/_lib/column.pyx b/python/cudf/cudf/_lib/column.pyx index 428db210532..404fea2e6d4 100644 --- a/python/cudf/cudf/_lib/column.pyx +++ b/python/cudf/cudf/_lib/column.pyx @@ -155,7 +155,11 @@ cdef class Column: ) if value is not None: - required_size = bitmask_allocation_size_bytes(self.base_size) + # base_size may be zero for a struct column with no + # children, but the column may have non-zero length. + required_size = bitmask_allocation_size_bytes( + max(self.base_size, self._size) + ) if value.size < required_size: error_msg = ( "The Buffer for mask is smaller than expected, " @@ -605,7 +609,9 @@ cdef class Column: else: mask = as_buffer( data=mask_ptr, - size=bitmask_allocation_size_bytes(base_size), + size=bitmask_allocation_size_bytes( + max(size+offset, base_size) + ), owner=mask_owner, exposed=True ) diff --git a/python/cudf/cudf/tests/test_struct.py b/python/cudf/cudf/tests/test_struct.py index 6573f89fd83..2ffa3c07995 100644 --- a/python/cudf/cudf/tests/test_struct.py +++ b/python/cudf/cudf/tests/test_struct.py @@ -394,18 +394,7 @@ def test_struct_with_null_memory_usage(): assert s.memory_usage() == 272 -@pytest.mark.parametrize( - "zlice", - [ - pytest.param( - slice(0, 3), - marks=pytest.mark.xfail( - reason="https://github.com/rapidsai/cudf/issues/13305" - ), - ), - slice(1, 4), - ], -) +@pytest.mark.parametrize("zlice", [slice(0, 3), slice(1, 4)]) def test_struct_empty_children_nulls_slice(zlice): values = [None, {}, {}, None]