From f9a4e36ba96f643931e9792bb1f68606490fc7fd Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 23 Apr 2026 11:28:18 +0200 Subject: [PATCH 1/3] Allow arbitrary SQL setup statements (INSTALL, LOAD, SET, etc.) Relax the grammar's other_sql_statement rule to accept any non-delimiter tokens, so statements like INSTALL/LOAD/SET/ATTACH parse without error. Execute these setup statements before the main query in the pipeline. Flip DDL detection in DuckDB and SQLite readers to a returns_rows whitelist, so unknown statement types are handled gracefully. Co-Authored-By: Claude Opus 4.6 --- src/execute/mod.rs | 5 +++++ src/reader/duckdb.rs | 26 +++++++++++++------------- src/reader/sqlite.rs | 24 +++++++++++++----------- tree-sitter-ggsql/grammar.js | 21 ++++++++------------- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/execute/mod.rs b/src/execute/mod.rs index 82c9e1c0..e5597ff9 100644 --- a/src/execute/mod.rs +++ b/src/execute/mod.rs @@ -949,6 +949,11 @@ pub fn prepare_data_with_reader(query: &str, reader: &dyn Reader) -> Result { - const exclude_pattern = /[^\s;(),'"WwSsCcIiUuDdVv]+/; - return prec(-1, repeat1(choice( - $.sql_keyword, - token(exclude_pattern), // Tokens not starting with excluded letters - $.string, - $.number, - $.subquery, - ',', '(', ')', '*', '.', '=' - ))); - }, + other_sql_statement: $ => prec(-1, repeat1(choice( + $.sql_keyword, + token(/[^\s;(),'"]+/), + $.string, + $.number, + $.subquery, + ',', '(', ')', '*', '.', '=' + ))), // Subquery in parentheses - fully recursive, can contain any SQL // Prioritizes WITH/SELECT statements, falls back to token-by-token parsing From 4c4423fc36f9327ab7c4a69075bbbf22d7b59e76 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 24 Apr 2026 10:38:49 +0200 Subject: [PATCH 2/3] add news item --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17223518..5d883363 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ in the Jupyter kernel (#360) - Reverted an earlier decision to materialize CTEs and the global query in Rust before registering them back to the backend. We now keep the data purely on the backend until the layer query as was always intended (#363) +- Relieved some grammatical constraints on the SQL-portion before the VISUALISE +portion (#364). ### Removed From 2f79acd8eb115ac5cc063ae843b33bb5cfdfe245 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 24 Apr 2026 10:41:13 +0200 Subject: [PATCH 3/3] candles in pentagram shape for clippy --- src/reader/duckdb.rs | 7 +------ src/reader/sqlite.rs | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/reader/duckdb.rs b/src/reader/duckdb.rs index 5edc6872..a3bb01ef 100644 --- a/src/reader/duckdb.rs +++ b/src/reader/duckdb.rs @@ -399,12 +399,7 @@ impl Reader for DuckDBReader { // Rewrite ggsql:name → __ggsql_data_name__ in SQL let sql = super::data::rewrite_namespaced_sql(sql)?; - let first_word = sql - .trim() - .split_whitespace() - .next() - .unwrap_or("") - .to_uppercase(); + let first_word = sql.split_whitespace().next().unwrap_or("").to_uppercase(); let returns_rows = matches!( first_word.as_str(), "SELECT" | "WITH" | "DESCRIBE" | "SHOW" | "EXPLAIN" | "FROM" diff --git a/src/reader/sqlite.rs b/src/reader/sqlite.rs index a9ae51ed..310cb1c4 100644 --- a/src/reader/sqlite.rs +++ b/src/reader/sqlite.rs @@ -362,12 +362,7 @@ impl Reader for SqliteReader { // Rewrite ggsql:name → __ggsql_data_name__ in SQL let sql = super::data::rewrite_namespaced_sql(sql)?; - let first_word = sql - .trim() - .split_whitespace() - .next() - .unwrap_or("") - .to_uppercase(); + let first_word = sql.split_whitespace().next().unwrap_or("").to_uppercase(); let returns_rows = matches!( first_word.as_str(), "SELECT" | "WITH" | "DESCRIBE" | "SHOW" | "EXPLAIN" | "FROM"