sqlglot
sqlglot copied to clipboard
Postgres parsing falls back to command for `CREATE TYPE`
First and foremost: thank you!
Currently, postgres types (enums) can only be processed using the fallback COMMAND expression.
It would be nice if we could get dedicated AST expression nodes for type creation.
Current behavior:
>>> from sqlglot import parse_one
>>> testsql = '''CREATE TYPE book_type as ENUM (
'FICTION',
'NONFICTION'
)'''
>>> parse_one(testsql, 'postgres')
'''CREATE TYPE book_type AS ENUM (
'FICTION',
'NONFICTION'
)' contains unsupported syntax. Falling back to parsing as a 'Command'.'''
In a more ideal world, this would instead return eg an Create(Type) structure instead of just the command.
I'd like to work on this myself. Is a PR welcome?
@devfros More than welcome, thank you!