LucaCappelletti94 commented on code in PR #2437:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2437#discussion_r3894810031


##########
tests/sqlparser_oracle.rs:
##########
@@ -539,3 +539,13 @@ fn test_insert_without_alias() {
         if matches!(&*source, Query { body, .. } if matches!(&**body, 
SetExpr::Values(_)))
     ));
 }
+
+#[test]
+fn parse_oracle_create_vector_index() {
+    // Oracle's specialized clauses (ORGANIZATION / DISTANCE / WITH TARGET
+    // ACCURACY / PARAMETERS) are not yet parsed; the forms it shares with the
+    // common grammar — an expression target and an `INCLUDE` list — 
round-trip.
+    oracle().verified_stmt("CREATE VECTOR INDEX g_idx ON galaxies(embedding)");
+    oracle().verified_stmt("CREATE VECTOR INDEX g_idx ON 
galaxies(VEC_DISTANCE(embedding))");
+    oracle().verified_stmt("CREATE VECTOR INDEX g_idx ON galaxies(embedding) 
INCLUDE (id)");
+}

Review Comment:
   None of these inputs are valid Oracle statements, and the common test 
already covers permissive parsing of the shared prefix across every dialect. 
Since correct Oracle statements are not currently supported, it does not make 
sense to test for incorrect ones even though this implementation parses them 
without erroring out, which I am unsure whether that is desirable.
   
   ```suggestion
   ```



##########
src/keywords.rs:
##########


Review Comment:
   `VECTOR` likely should be a keyword
   
   ```suggestion
       VECTOR,
       VERBOSE,
   ```



##########
src/parser/mod.rs:
##########
@@ -5311,6 +5311,15 @@ impl<'a> Parser<'a> {
             self.parse_create_schema(or_replace)
         } else if self.parse_keyword(Keyword::WAREHOUSE) {
             self.parse_create_warehouse(or_replace).map(Into::into)
+        } else if matches!(
+            &self.peek_token_ref().token,
+            Token::Word(w) if w.keyword == Keyword::NoKeyword && 
w.value.eq_ignore_ascii_case("VECTOR")
+        ) {

Review Comment:
   After adding the keyword, you can now replace this with:
   
   ```suggestion
           } else if self.parse_keyword(Keyword::VECTOR) {
   ```



##########
tests/sqlparser_mssql.rs:
##########
@@ -2941,3 +2941,12 @@ fn parse_bracket_quoted_function_argument_name() {
         }])
     );
 }
+
+#[test]
+fn parse_mssql_create_vector_index() {
+    // SQL Server's form: bracket-quoted names and a `WITH (...)` options 
clause
+    // (`METRIC` / `TYPE` / `MAXDOP`).
+    ms().verified_stmt(
+        "CREATE VECTOR INDEX vec_idx ON [dbo].[articles]([title_vector]) WITH 
(METRIC = 'cosine', TYPE = 'DiskANN', MAXDOP = 8)",
+    );

Review Comment:
   The ON syntax from [SQL Server CREATE VECTOR INDEX 
grammar](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-vector-index-transact-sql)
 still does not parse, here is a red test for it:
   
   ```suggestion
       );
       ms().verified_stmt(
           "CREATE VECTOR INDEX vec_idx ON [dbo].[articles]([title_vector]) 
WITH (METRIC = 'cosine', TYPE = 'DiskANN', MAXDOP = 8) ON [PRIMARY]",
       );
   ```



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