test: add example failing test for recursive datatype DDLs
If we create a table with a nested type (such as struct, map, or union), then all the children types, (such as ENUMS) need to have already been created with an eg CREATE TYPE severity AS ENUM [<values>] DDL statement. See the duckdb docs
This fails with
sqlalchemy.exc.ProgrammingError: (duckdb.duckdb.CatalogException) Catalog Error: Type with name severity does not exist!
Did you mean "varint"?
[SQL:
CREATE TABLE test_struct (
id INTEGER NOT NULL,
struct STRUCT("severity" severity),
map MAP(VARCHAR, severity),
"union" UNION("age" INTEGER, "severity" severity),
PRIMARY KEY (id)
)
]
(Background on this error at: https://sqlalche.me/e/14/f405)
I started trying to figure out what the needed change is, but I got stumped. If you point me in the right direction, I can write the fix.
(For myself: test with uv tool run poetry run pytest -k test_double_nested_type_ddl duckdb_engine/tests/test_datatypes.py )
Actually, I think the nesting merely surfaces the problem, but I think the underlying cause is that NONE of the custom types are created before the tables are. See https://github.com/Mause/duckdb_engine/pull/1237