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
1 change: 0 additions & 1 deletion cpp/src/column/column_factories.cu
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ std::unique_ptr<cudf::column> column_from_scalar_dispatch::operator()<cudf::stru
cuda::stream_ref stream,
rmm::device_async_resource_ref mr) const
{
CUDF_EXPECTS(size != 0, "0-length struct column is unsupported.");
auto& ss = static_cast<scalar_type_t<cudf::struct_view> const&>(value);
auto iter = cuda::make_constant_iterator(0);

Expand Down
18 changes: 18 additions & 0 deletions cpp/tests/column/factories_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,24 @@ TEST_F(ColumnFactoryTest, FromStructScalar) { struct_from_scalar(true); }

TEST_F(ColumnFactoryTest, FromStructScalarNull) { struct_from_scalar(false); }

void struct_from_scalar_zero_size(bool is_valid)
{
cudf::test::fixed_width_column_wrapper<int> col0{1};
cudf::test::strings_column_wrapper col1{"abc"};
cudf::test::lists_column_wrapper<int> col2{{1, 2, 3}};

std::vector<cudf::column_view> src_children({col0, col1, col2});
auto value = cudf::struct_scalar(src_children, is_valid);
auto result = cudf::make_column_from_scalar(value, 0);

auto const expected = cudf::empty_like(cudf::make_column_from_scalar(value, 1)->view());
CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, *expected);
}

TEST_F(ColumnFactoryTest, FromStructScalarWithZeroSize) { struct_from_scalar_zero_size(true); }

TEST_F(ColumnFactoryTest, FromStructScalarNullWithZeroSize) { struct_from_scalar_zero_size(false); }

TEST_F(ColumnFactoryTest, FromScalarErrors)
{
if (cudf::strings::is_large_strings_enabled()) { return; }
Expand Down
6 changes: 6 additions & 0 deletions python/cudf_polars/tests/expressions/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@ def test_struct_literal_field_is_broadcast(
)
q = df.select(pl.struct("a", x="c", y=literal).alias("struct").struct.field("y"))
assert_gpu_result_equal(q, engine=engine)


def test_group_by_struct_of_literals_empty_frame(engine: pl.GPUEngine) -> None:
df = pl.LazyFrame({"g": [10, 10, 20], "n": [1, 2, 3]}).head(0)
q = df.group_by("g").agg(pl.struct(pl.lit(7).alias("lhs"), pl.lit(7).alias("rhs")))
assert_gpu_result_equal(q, engine=engine, check_row_order=False)
Loading