mvzink commented on code in PR #2029:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2029#discussion_r2350170962


##########
src/parser/mod.rs:
##########
@@ -7061,19 +7061,27 @@ impl<'a> Parser<'a> {
     pub fn parse_create_index(&mut self, unique: bool) -> Result<Statement, 
ParserError> {
         let concurrently = self.parse_keyword(Keyword::CONCURRENTLY);
         let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, 
Keyword::EXISTS]);
+
+        let mut using = None;
+
         let index_name = if if_not_exists || !self.parse_keyword(Keyword::ON) {
             let index_name = self.parse_object_name(false)?;
+            // MySQL allows `USING index_type` either before or after `ON 
table_name`
+            using = self.parse_using_index_type_clause()?;
             self.expect_keyword_is(Keyword::ON)?;
             Some(index_name)
         } else {
             None
         };
+
         let table_name = self.parse_object_name(false)?;
-        let using = if self.parse_keyword(Keyword::USING) {
-            Some(self.parse_index_type()?)
-        } else {
-            None
-        };
+
+        if let Some(second_using) = self.parse_using_index_type_clause()? {
+            if using.is_some() {
+                return Err(ParserError::ParserError("USING already 
specified".into()));

Review Comment:
   MySQL actually allows specifying it in both positions and discards the first 
if both are present; I think we should do the same. I think then this entire 
block can just be `using = 
self.parse_optional_using_then_index_type()?.or(using);`



##########
src/parser/mod.rs:
##########
@@ -8588,6 +8596,14 @@ impl<'a> Parser<'a> {
         }
     }
 
+    pub fn parse_using_index_type_clause(&mut self) -> 
Result<Option<IndexType>, ParserError> {

Review Comment:
   `parse_optional_using_then_index_type` already exists



##########
src/parser/mod.rs:
##########
@@ -7061,19 +7061,27 @@ impl<'a> Parser<'a> {
     pub fn parse_create_index(&mut self, unique: bool) -> Result<Statement, 
ParserError> {
         let concurrently = self.parse_keyword(Keyword::CONCURRENTLY);
         let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, 
Keyword::EXISTS]);
+
+        let mut using = None;

Review Comment:
   Seems okay IMO.



-- 
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