-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(postgres): parse CREATE TYPE statements #7616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
dc71fa9
e121b10
709f43d
2d8b139
e7d47c2
48e31f0
0838ab3
9f4a3f3
2eff51d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -644,6 +644,7 @@ class Parser: | |
| TokenType.INDEX, | ||
| TokenType.PROCEDURE, | ||
| TokenType.TRIGGER, | ||
| TokenType.TYPE, | ||
| *DB_CREATABLES, | ||
| } | ||
|
|
||
|
|
@@ -754,6 +755,7 @@ class Parser: | |
| TokenType.UNPIVOT, | ||
| TokenType.UPDATE, | ||
| TokenType.USE, | ||
| TokenType.TYPE, | ||
|
georgesittas marked this conversation as resolved.
Outdated
|
||
| TokenType.VOLATILE, | ||
| TokenType.WINDOW, | ||
| TokenType.CURRENT_CATALOG, | ||
|
|
@@ -2485,6 +2487,20 @@ def extend_props(temp_props: exp.Properties | None) -> None: | |
|
|
||
| this = trigger_name | ||
| extend_props(exp.Properties(expressions=[trigger_props] if trigger_props else [])) | ||
| elif create_token_type == TokenType.TYPE: | ||
| this = self._parse_table_parts(schema=True) | ||
| if not this or not self._match(TokenType.ALIAS): | ||
| return self._parse_as_command(start) | ||
|
Comment on lines
+2491
to
+2492
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually need this fallback? It seems that the non- 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing that fallback regressed tests, unsupported CREATE TYPE forms no longer roundtrip as Command. The idea was to to scope this PR to |
||
|
|
||
| if self._match(TokenType.ENUM): | ||
| expression = exp.DataType( | ||
| this=exp.DType.ENUM, | ||
| expressions=self._parse_wrapped_csv(self._parse_string), | ||
| ) | ||
| elif self._match(TokenType.L_PAREN, advance=False): | ||
| expression = self._parse_schema() | ||
| else: | ||
| return self._parse_as_command(start) | ||
| elif create_token_type in self.DB_CREATABLES: | ||
| table_parts = self._parse_table_parts( | ||
| schema=True, is_db_reference=create_token_type == TokenType.SCHEMA | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.