iffyio commented on code in PR #1460:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1460#discussion_r1792219167


##########
src/dialect/postgresql.rs:
##########
@@ -138,6 +138,14 @@ impl Dialect for PostgreSqlDialect {
     fn parse_statement(&self, parser: &mut Parser) -> Option<Result<Statement, 
ParserError>> {
         if parser.parse_keyword(Keyword::COMMENT) {
             Some(parse_comment(parser))
+        } else if parser.parse_keyword(Keyword::CREATE) {
+            match parse_create(parser) {
+                Some(result) => Some(result),
+                None => {
+                    parser.prev_token(); // unconsume the CREATE if we didn't 
end up parsing anything
+                    None
+                }

Review Comment:
   it might be possible to simplify this if we call `prev_token()` before 
calling `parse_create`? thinking since the latter already returns an Option 
representing the same result



##########
src/ast/mod.rs:
##########
@@ -3181,6 +3181,14 @@ pub enum Statement {
         representation: UserDefinedTypeRepresentation,
     },
     /// ```sql
+    /// CREATE TYPE <name> AS ENUM
+    /// ```
+    /// Note: this is a PostgreSQL-specific statement. See 
<https://www.postgresql.org/docs/current/sql-createtype.html>
+    CreateTypeAsEnum {
+        name: ObjectName,
+        labels: Vec<Ident>,
+    },

Review Comment:
   I'm thinking it could make sense to include it as part of the existing 
`CreateType`, especially since its already an enum there wouldn't be as much of 
disadvantage in terms of backwards compatibility? then going forward we'd be 
able to extend it in a similar manner with future extensions to the statement. 
something like:
   ```rust
   pub enum UserDefinedTypeRepresentation {
       Composite {
           attributes: Vec<UserDefinedTypeCompositeAttributeDef>,
       },
       // new variant
       Enum(CreateTypeEnum)
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@datafusion.apache.org
For additional commands, e-mail: dev-h...@datafusion.apache.org

Reply via email to