Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2450 +/- ##
==========================================
+ Coverage 81.02% 81.03% +0.01%
==========================================
Files 42 42
Lines 33436 33471 +35
Branches 33436 33471 +35
==========================================
+ Hits 27090 27123 +33
- Misses 2789 2792 +3
+ Partials 3557 3556 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| 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)"); |
There was a problem hiding this 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.
| duckdb().verified_stmt("SELECT column_name FROM (SUMMARIZE SELECT 42 AS answer)"); | |
| duckdb().verified_stmt("SELECT column_name FROM (SUMMARIZE SELECT 42 AS answer)"); | |
| duckdb().verified_stmt("SELECT (SUMMARIZE users)"); |
There was a problem hiding this 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.
| self.peek_one_of_keywords(&[Keyword::SELECT, Keyword::WITH]) | |
| .is_some() | |
| || (self.dialect.supports_summarize() && self.peek_keyword(Keyword::SUMMARIZE)) |
|
Thanks for the review. Both comments have been addressed in
The workflows for the latest commit are currently waiting for maintainer approval. Could you please re-review the changes and approve the Actions runs when convenient? |
LucaCappelletti94
left a comment
There was a problem hiding this comment.
Since the fuzzer found a bug in this code, please run it on this branch before the next round. fuzz_duckdb_accepts checks DuckDbDialect against DuckDB's own parser and fails when DuckDB accepts a SELECT that the dialect rejects. That is how SUMMARIZE value turned up. fuzz_parse_roundtrip fails when the SQL that Display renders no longer parses.
To start it, from fuzz/ on nightly (see docs/fuzzing.md):
cargo install cargo-fuzz
cd fuzz
cargo +nightly fuzz run fuzz_duckdb_accepts fuzz_seeds -- -max_total_time=600
cargo +nightly fuzz run fuzz_parse_roundtrip fuzz_seeds -- -max_total_time=600Crashes land in fuzz/artifacts/<target>/ and replay with cargo +nightly fuzz run <target> <crash-file>. Some of them also fail on main, so rewrite each one without SUMMARIZE (for example SUMMARIZE t as SELECT * FROM t). If it still fails, the gap predates this PR. If it only fails with SUMMARIZE, it needs fixing here.
If you find bugs that predate this PR, and most likely you will, if you have time we would certainly appreciate contributions to fix them.
| Keyword::VALUES, | ||
| Keyword::VALUE, | ||
| Keyword::FROM, | ||
| Keyword::TABLE, | ||
| ]) | ||
| .is_some() |
There was a problem hiding this 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.
| Keyword::VALUES, | |
| Keyword::VALUE, | |
| Keyword::FROM, | |
| Keyword::TABLE, | |
| ]) | |
| .is_some() | |
| Keyword::FROM, | |
| Keyword::TABLE, | |
| ]) | |
| .is_some() | |
| || (self.peek_keyword(Keyword::VALUES) | |
| && self.peek_nth_token_ref(1).token == Token::LParen) |
| 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)"); |
There was a problem hiding this 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.
| duckdb().verified_stmt("SUMMARIZE VALUES (1.0), (6754950520)"); | |
| duckdb().verified_stmt("SUMMARIZE VALUES (1.0), (6754950520)"); | |
| duckdb().verified_stmt("SUMMARIZE value"); | |
| duckdb().verified_stmt("SUMMARIZE values"); |
Adds DuckDB
SUMMARIZEsupport for named tables and query inputs such asSELECT,FROM,VALUES, parenthesized queries, and CTEs.The syntax is represented as a query AST node so it can also be used in subqueries, for example
SELECT column_name FROM (SUMMARIZE SELECT 42 AS answer).Reference: https://duckdb.org/docs/stable/guides/meta/summarize.html