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


##########
src/parser/mod.rs:
##########
@@ -15173,6 +15179,27 @@ impl<'a> Parser<'a> {
         self.parse_remaining_set_exprs(expr, precedence)
     }
 
+    fn parse_summarize_target(&mut self) -> Result<SummarizeTarget, 
ParserError> {
+        if self
+            .peek_one_of_keywords(&[
+                Keyword::SELECT,
+                Keyword::WITH,
+                Keyword::VALUES,
+                Keyword::VALUE,
+                Keyword::FROM,
+                Keyword::TABLE,
+            ])
+            .is_some()

Review Comment:
   You should route `VALUES` to the query branch only when a `(` follows, and 
drop `VALUE`. DuckDB 1.4.4 reads `SUMMARIZE value` and `SUMMARIZE values` as 
tables named `value` and `values` and rejects `SUMMARIZE VALUE (1)`, but this 
branch fails both table forms with `Expected: (, found: EOF`. The 
`fuzz_duckdb_accepts` oracle reports it.
   
   ```suggestion
                   Keyword::FROM,
                   Keyword::TABLE,
               ])
               .is_some()
               || (self.peek_keyword(Keyword::VALUES)
                   && self.peek_nth_token_ref(1).token == Token::LParen)
   ```



##########
tests/sqlparser_duckdb.rs:
##########
@@ -925,3 +925,73 @@ fn test_duckdb_lambda_function() {
     let sql_transform = "SELECT list_transform([1, 2, 3], lambda x : x * 2)";
     duckdb().verified_stmt(sql_transform);
 }
+
+#[test]
+fn parse_summarize() {
+    duckdb().verified_stmt("SUMMARIZE users");
+    duckdb().verified_stmt(r#"SUMMARIZE "analytics"."events""#);
+    duckdb().verified_stmt("SUMMARIZE 'users'");
+    duckdb().verified_stmt("SUMMARIZE SELECT * FROM users");
+    duckdb().verified_stmt("SUMMARIZE FROM users");
+    duckdb().verified_stmt("SUMMARIZE VALUES (1.0), (6754950520)");

Review Comment:
   You should cover the table names that collide with row constructors. Both 
lines fail on the current head and pass with the change above.
   
   ```suggestion
       duckdb().verified_stmt("SUMMARIZE VALUES (1.0), (6754950520)");
       duckdb().verified_stmt("SUMMARIZE value");
       duckdb().verified_stmt("SUMMARIZE values");
   ```



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