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


##########
tests/sqlparser_duckdb.rs:
##########
@@ -925,3 +925,21 @@ 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)");
+    duckdb().verified_stmt("SUMMARIZE (SELECT 42 AS answer)");
+    duckdb().verified_stmt("SUMMARIZE WITH users AS (SELECT 1 AS id) SELECT * 
FROM users");
+    duckdb().verified_stmt("SELECT column_name FROM (SUMMARIZE SELECT 42 AS 
answer)");

Review Comment:
   You should cover `SUMMARIZE` as a scalar subquery. DuckDB 1.4.4 accepts 
`SELECT (SUMMARIZE users)`, but this branch fails with `Expected: ), found: 
users`.
   
   ```suggestion
       duckdb().verified_stmt("SELECT column_name FROM (SUMMARIZE SELECT 42 AS 
answer)");
       duckdb().verified_stmt("SELECT (SUMMARIZE users)");
   ```



##########
src/parser/mod.rs:
##########


Review Comment:
   You should let `peek_sub_query` recognise `SUMMARIZE`. DuckDB 1.4.4 accepts 
`SELECT (SUMMARIZE users)`, but this branch fails with `Expected: ), found: 
users` because the expression parser only treats `SELECT` and `WITH` as 
subquery heads.
   
   ```suggestion
       self.peek_one_of_keywords(&[Keyword::SELECT, Keyword::WITH])
               .is_some()
               || (self.dialect.supports_summarize() && 
self.peek_keyword(Keyword::SUMMARIZE))
   ```



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