1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
# name: test/sql/alter/list/drop_column_in_struct.test
# description: Test dropping fields in a STRUCT.
# group: [list]
statement ok
CREATE TABLE test(s STRUCT(i INTEGER, j INTEGER)[])
statement ok
INSERT INTO test VALUES ([ROW(1, 1)]), ([ROW(2, 2)])
# Try to drop element from the list.
statement error
ALTER TABLE test DROP COLUMN s.element
----
<REGEX>:Catalog Error.*Cannot drop field.*not a struct.*
# Now drop a STRUCT field.
statement ok
ALTER TABLE test DROP COLUMN s.element.j
query I
SELECT * FROM test
----
[{'i': 1}]
[{'i': 2}]
statement ok
DROP TABLE test;
statement ok
CREATE TABLE test(
s STRUCT(
a STRUCT(i INTEGER, j INTEGER)[]
)
)
statement ok
INSERT INTO test VALUES (ROW([ROW(1, 1)])), (ROW([ROW(2, 2)]))
# Drop another (one more nesting level) STRUCT field.
statement ok
ALTER TABLE test DROP COLUMN s.a.element.i
query I
SELECT * FROM test
----
{'a': [{'j': 1}]}
{'a': [{'j': 2}]}
|