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


##########
src/parser/mod.rs:
##########
@@ -7833,6 +7833,15 @@ impl<'a> Parser<'a> {
         let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, 
Keyword::EXISTS]);
         let table_name = self.parse_object_name(allow_unquoted_hyphen)?;
 
+        // PostgreSQL PARTITION OF for child partition tables
+        let partition_of = if dialect_of!(self is PostgreSqlDialect | 
GenericDialect)
+            && self.parse_keywords(&[Keyword::PARTITION, Keyword::OF])

Review Comment:
   ```suggestion
           let partition_of = if self.parse_keywords(&[Keyword::PARTITION, 
Keyword::OF])
   ```
   If possible we can skiip the dialect check and let the parser accept the 
`PARTITION OF` clause whenever it shows up in an input sql



##########
src/parser/mod.rs:
##########
@@ -7993,6 +8011,60 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parse PostgreSQL partition bound specification for PARTITION OF.
+    ///
+    /// Parses: `FOR VALUES partition_bound_spec | DEFAULT`

Review Comment:
   ```suggestion
       /// Parse [ForValues] of a `PARTITION OF` clause.
   ```



##########
src/parser/mod.rs:
##########
@@ -7993,6 +8011,60 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parse PostgreSQL partition bound specification for PARTITION OF.
+    ///
+    /// Parses: `FOR VALUES partition_bound_spec | DEFAULT`
+    ///
+    /// 
[PostgreSQL](https://www.postgresql.org/docs/current/sql-createtable.html)
+    fn parse_partition_for_values(&mut self) -> Result<ForValues, ParserError> 
{
+        if self.parse_keyword(Keyword::DEFAULT) {
+            return Ok(ForValues::Default);
+        }
+
+        self.expect_keywords(&[Keyword::FOR, Keyword::VALUES])?;
+
+        if self.parse_keyword(Keyword::IN) {
+            // FOR VALUES IN (expr, ...)
+            self.expect_token(&Token::LParen)?;
+            let values = self.parse_comma_separated(Parser::parse_expr)?;
+            self.expect_token(&Token::RParen)?;
+            Ok(ForValues::In(values))
+        } else if self.parse_keyword(Keyword::FROM) {
+            // FOR VALUES FROM (...) TO (...)
+            self.expect_token(&Token::LParen)?;
+            let from = 
self.parse_comma_separated(Parser::parse_partition_bound_value)?;
+            self.expect_token(&Token::RParen)?;
+            self.expect_keyword(Keyword::TO)?;
+            self.expect_token(&Token::LParen)?;
+            let to = 
self.parse_comma_separated(Parser::parse_partition_bound_value)?;
+            self.expect_token(&Token::RParen)?;
+            Ok(ForValues::From { from, to })
+        } else if self.parse_keyword(Keyword::WITH) {
+            // FOR VALUES WITH (MODULUS n, REMAINDER r)
+            self.expect_token(&Token::LParen)?;
+            self.expect_keyword(Keyword::MODULUS)?;
+            let modulus = self.parse_literal_uint()?;
+            self.expect_token(&Token::Comma)?;
+            self.expect_keyword(Keyword::REMAINDER)?;
+            let remainder = self.parse_literal_uint()?;
+            self.expect_token(&Token::RParen)?;
+            Ok(ForValues::With { modulus, remainder })
+        } else {
+            self.expected("IN, FROM, or WITH after FOR VALUES", 
self.peek_token())
+        }
+    }
+
+    /// Parse a single partition bound value (MINVALUE, MAXVALUE, or 
expression).

Review Comment:
   ```suggestion
       /// Parse a single [PartitionBoundValue].
   ```



##########
src/ast/ddl.rs:
##########
@@ -3044,6 +3062,76 @@ impl fmt::Display for CreateTable {
     }
 }
 
+/// PostgreSQL partition bound specification for PARTITION OF.

Review Comment:
   ```suggestion
   /// PostgreSQL partition bound specification for `PARTITION OF`.
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to