Skip to content

Commit

Permalink
[Test] More STRUCT cast tests (duckdb#15578)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin authored Jan 7, 2025
2 parents add5120 + e8c6041 commit 12d1051
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/sql/types/struct/struct_cast_superset.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# name: test/sql/types/struct/struct_cast_superset.test
# description: Test STRUCT cast + UNION BY NAME
# group: [struct]

require parquet

statement ok
PRAGMA enable_verification

statement ok
CREATE TABLE t1 (s1 STRUCT(a INT, b INT));

statement ok
INSERT INTO t1 VALUES ({a: 42, b: 43});

statement ok
CREATE TABLE t2 (s1 STRUCT(a INT, c INT));

statement ok
INSERT INTO t2 VALUES ({a: 100, c: 101});

statement ok
COPY t1 TO '__TEST_DIR__/struct_cast_t1.parquet' (FORMAT 'parquet');

statement ok
COPY t2 TO '__TEST_DIR__/struct_cast_t2.parquet' (FORMAT 'parquet');

query I
SELECT * FROM read_parquet('__TEST_DIR__/struct_cast_*.parquet', union_by_name = TRUE);
----
{'a': 42, 'b': 43, 'c': NULL}
{'a': 100, 'b': NULL, 'c': 101}

query I
SELECT {'a': {'e1': 42, 'e2': 42}} AS c
UNION ALL BY NAME SELECT {'a': {'e2': 'hello', 'e3': 'world'}, 'b': '100'} AS c;
----
{'a': {'e1': 42, 'e2': 42, 'e3': NULL}, 'b': NULL}
{'a': {'e1': NULL, 'e2': hello, 'e3': world}, 'b': 100}

0 comments on commit 12d1051

Please sign in to comment.