Skip to content

Commit 42b6596

Browse files
committed
empty structs are supported
1 parent 45e1670 commit 42b6596

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

external/duckdb

Submodule duckdb updated 194 files

tests/fast/arrow/test_arrow_types.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ def test_null_type(self, duckdb_cursor):
1616
# NULL type now round-trips faithfully (previously it was coerced to int32)
1717
assert rel["data"] == arrow_table["data"]
1818

19-
def test_invalid_struct(self, duckdb_cursor):
19+
def test_empty_struct(self, duckdb_cursor):
20+
# Empty structs are now supported by DuckDB core. This previously raised
21+
# "Attempted to convert a STRUCT with no fields to DuckDB which is not supported";
22+
# the core check was removed and empty structs now round-trip faithfully.
2023
empty_struct_type = pa.struct([])
21-
22-
# Create an empty array with the defined struct type
23-
empty_array = pa.array([], type=empty_struct_type)
24-
arrow_table = pa.Table.from_arrays([empty_array], schema=pa.schema([("data", empty_struct_type)])) # noqa: F841
25-
with pytest.raises(
26-
duckdb.InvalidInputException,
27-
match="Attempted to convert a STRUCT with no fields to DuckDB which is not supported",
28-
):
29-
duckdb_cursor.sql("select * from arrow_table").fetchall()
24+
arrow_table = pa.Table.from_arrays( # noqa: F841
25+
[pa.array([None, None], type=empty_struct_type)],
26+
schema=pa.schema([("data", empty_struct_type)]),
27+
)
28+
result = duckdb_cursor.sql("select * from arrow_table").to_arrow_table()
29+
assert result["data"].type == empty_struct_type
30+
assert result["data"].to_pylist() == [None, None]
3031

3132
def test_invalid_union(self, duckdb_cursor):
3233
# Create a sparse union array from dense arrays

tests/fast/spark/test_spark_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def test_all_types_schema(self, spark):
5656
medium_enum,
5757
large_enum,
5858
'union',
59+
empty_struct,
5960
fixed_int_array,
6061
fixed_varchar_array,
6162
fixed_nested_int_array,

0 commit comments

Comments
 (0)