feat(postgres): parse CREATE TYPE statements#7616
Merged
georgesittas merged 9 commits intotobymao:mainfrom May 8, 2026
Merged
Conversation
georgesittas
reviewed
May 7, 2026
VaggelisD
reviewed
May 7, 2026
georgesittas
reviewed
May 7, 2026
Collaborator
georgesittas
left a comment
There was a problem hiding this comment.
This is looking better. Left a few more comments to clean it up even more. There may be an opportunity to support the whole syntax spec in one fell swoop.
Comment on lines
+2491
to
+2492
| if not this or not self._match(TokenType.ALIAS): | ||
| return self._parse_as_command(start) |
Collaborator
There was a problem hiding this comment.
Do we actually need this fallback? It seems that the non-AS syntax is:
CREATE TYPE name (
INPUT = input_function,
OUTPUT = output_function
[ , RECEIVE = receive_function ]
[ , SEND = send_function ]
[ , TYPMOD_IN = type_modifier_input_function ]
[ , TYPMOD_OUT = type_modifier_output_function ]
[ , ANALYZE = analyze_function ]
[ , SUBSCRIPT = subscript_function ]
[ , INTERNALLENGTH = { internallength | VARIABLE } ]
[ , PASSEDBYVALUE ]
[ , ALIGNMENT = alignment ]
[ , STORAGE = storage ]
[ , LIKE = like_type ]
[ , CATEGORY = category ]
[ , PREFERRED = preferred ]
[ , DEFAULT = default ]
[ , ELEMENT = element ]
[ , DELIMITER = delimiter ]
[ , COLLATABLE = collatable ]
)
CREATE TYPE name
I think we may be able to "just" parse these with the existing logic as "properties", without having to add any more logic.
Contributor
Author
There was a problem hiding this comment.
Removing that fallback regressed tests, unsupported CREATE TYPE forms no longer roundtrip as Command. The idea was to to scope this PR to AS ENUM / AS (...) and avoid partial ASTs
added 2 commits
May 8, 2026 09:52
georgesittas
reviewed
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
• Solves #7612
• Adds AST parsing for Postgres enum and composite
CREATE TYPE• Reuses
exp.Create,exp.DataType,exp.Schema, andexp.ColumnDef• Adds Postgres dialect tests