Commit Graph

80 Commits

Author SHA1 Message Date
Evan
9ec049b88a test(trino): cover remaining branches in inline UDF parsing
Adds cases for nested parens inside an `IF (...)` condition, a scalar
function literally named `function` outside a routine specification,
and an unbalanced `IF` condition, restoring 100% coverage on
superset/sql/dialects/trino.py required by unit-tests-required.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 10:16:11 -07:00
Evan
17dab48f60 fix(trino): detect inline UDFs after a preceding CTE in WITH clause
routine_mode only triggered when FUNCTION appeared immediately after
WITH, so a WITH clause defining a regular CTE before the inline UDF
(e.g. `WITH cte AS (...), FUNCTION f() ...`) never entered routine
mode, letting semicolons inside the function body incorrectly split
the statement. Detect FUNCTION as a fresh WITH-list entry whenever it
follows WITH or a top-level comma, not just at the very start.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 10:16:10 -07:00
Evan
ac63ff56cd fix(trino): correctly detect parenthesized IF blocks in routine bodies
Add type annotations to the module-level constants and local counters
in the Trino dialect, and fix the `IF (a > b) THEN` vs. scalar `IF(...)`
ambiguity: an IF immediately followed by `(` is now classified as a
procedural block only when the matching closing paren is followed by
THEN, otherwise as a scalar function call. Adds a regression test for
the parenthesized condition case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-21 10:16:10 -07:00
Evan
43813d0681 test(trino): cover missing-RETURN and semicolon-comment edge cases
Adds unit tests for the two Trino dialect branches the CI coverage gate
flagged as untested: a RETURN body with no following expression, and a
statement-terminating semicolon that carries an attached comment or has
no trailing statement.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 10:16:10 -07:00
Evan
f2209f3b13 fix(trino): support inline SQL UDFs (WITH FUNCTION ... BEGIN ... END)
sqlglot cannot parse Trino SQL routine syntax, so queries declaring
inline UDFs failed to parse in SQL Lab: the parser splits statements
on every semicolon (including the ones inside BEGIN ... END routine
bodies) and has no grammar for FUNCTION specifications in a WITH
clause. The upstream issue (tobymao/sqlglot#5178) was closed as low
priority, so this extends the Trino dialect on the Superset side.

The custom dialect keeps routine bodies intact when splitting
statements and parses inline function specifications into opaque
InlineUDF nodes that regenerate verbatim. Trino does not allow queries
inside SQL UDF bodies, so the opaque representation hides no table
references from Superset's security checks. The extensions only
activate on syntax that fails to parse today, so existing queries are
unaffected.

Fixes #26162

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 10:16:10 -07:00
Evan Rusackas
666b6805c4 test(sql): prove Oracle GROUP BY stays explicit for virtual-dataset charts (#42255)
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-21 09:59:34 -07:00
Evan Rusackas
b3757870cc fix(sqllab): apply SQL_QUERY_MUTATOR in SQL Lab when MUTATE_AFTER_SPLIT is set (#41127)
Co-authored-by: Lucas Wolkersdorfer <lucas.wolkersdorfer@rise-world.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 15:36:45 -07:00
Evan Rusackas
7b0969131f test(sql): prove ClickHouse parametric aggregates parse cleanly (#37285) (#41836)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-07-07 08:53:49 -07:00
Evan Rusackas
de5a31a2cf test(sql): prove Oracle GROUP BY is no longer rewritten to ordinals (#35414) (#41834)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-07-07 08:53:05 -07:00
Evan Rusackas
2aa43f6f0f fix(sql): stop sanitize_clause from rewriting user SQL semantics (#36113) (#41125)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-07-06 18:03:26 -07:00
Shaitan
2da2db6c7c feat(sql): schema-qualified table denylist + information_schema/lo_* defaults (#41120)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 16:57:45 +01:00
Shaitan
3651020014 fix(sql): cap parser input length via SQL_MAX_PARSE_LENGTH config (#40499)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: sha174n <pedro.sousa@preset.io>
Co-authored-by: Evan Rusackas <evan@preset.io>
2026-07-01 16:32:12 +01:00
Shaitan
215b207ae4 fix(sql): detect set operations and nested selects in subquery check (#38452)
Co-authored-by: sha174n <pedro.sousa@preset.io>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 20:27:32 -07:00
Jean Dupuis
b2e5f80db2 fix(sql): preserve multi-arg DISTINCT in sanitize_clause and format (#39340) 2026-06-19 13:02:50 -07:00
Shaitan
6a1091d576 fix(sql): broaden mutating-statement detection in SQL Lab parser (#40421)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: sha174n <pedro.sousa@preset.io>
2026-06-16 15:07:34 -07:00
Evan Rusackas
b85a2cdab1 fix: ODPS (MaxCompute) data source table preview failed (#38174)
Co-authored-by: zhutong6688 <zhutong66@163.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-06-05 17:57:44 -07:00
Shaitan
56fd991efd fix(dataset): unify validation for stored and adhoc SQL expressions (#40392)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 12:55:50 +01:00
Shaitan
f7f50a7977 fix(sqllab): quote CTAS target identifiers and validate tmp_table_name format (#40245)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03 12:55:25 +01:00
Shaitan
6eaee211aa fix(sqllab): require dataset match for raw query access (#40409)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 21:50:27 +01:00
Evan Rusackas
b97d3ef520 fix(api,sql): use json_response in Api.query and log dialect fallback (#40644)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-06-02 11:48:46 -07:00
Evan Rusackas
1632b235ae fix(sqllab): surface stacktrace in SQL Lab error responses (#28248) (#40585)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 10:41:39 -07:00
Evan Rusackas
c39a47cbac test(sql-parser): pin WITH+UNION as non-mutating across dialects (#25659) (#40138)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-05-20 10:08:21 -07:00
Alexandru Soare
b98bd2a07a fix(mcp): Block destructive DDL (DROP, TRUNCATE, ALTER) in execute_sql (#39621) 2026-05-20 14:29:15 +03:00
Evan Rusackas
b5ad4a7a07 test(sql-parser): pin TimescaleDB hyperfunctions parse on postgresql (#32028) (#40142)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-05-19 19:53:33 -07:00
Evan Rusackas
9bfa0642a1 test(sql-parser): pin quoted identifiers with spaces are not subqueries (#32541, #32684) (#40143)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-05-18 14:21:59 -07:00
Igor Khrol
3363b48180 fix(spark): register Spark SQLAlchemy dialect so spark:// URIs resolve to SparkEngineSpec (#38299)
Co-authored-by: Joe Li <joe@preset.io>
2026-05-12 12:33:17 -04:00
Beto Dealmeida
4311a15eb2 feat(sqlglot): Vertica dialect (#39969) 2026-05-08 14:34:34 -03:00
Vitor Avila
ad5e3170dd fix: OpenSearch dialect identifier delimiters (#39953) 2026-05-07 16:19:27 -03:00
Alexandru Soare
adfbbf1433 fix(sql): quote identifiers in transpile_to_dialect to fix case-sensitive column filters (#39521) 2026-05-06 10:53:09 +03:00
Vitor Avila
5af17c7976 fix(OpenSearch): OpenSearch dialect for sqlglot (#39538) 2026-04-22 12:17:15 -03:00
Luiz Otavio
0b419a07f5 fix: add comments to SQL clause validation (#39167) 2026-04-16 09:19:39 -03:00
Amin Ghadersohi
68067d7f44 fix(mcp): handle OAuth-authenticated databases in execute_sql (#39166) 2026-04-09 15:47:00 -04:00
Alexandru Soare
6465450b64 fix(firebolt): Firebolt SQL entered with EXCLUDE is rewritten to EXCEPT (#38742) 2026-03-19 10:21:50 -07:00
Beto Dealmeida
a854fa60a2 feat: apply RLS conservatively (#38683) 2026-03-17 10:20:09 -04:00
Michael S. Molina
357e35dc62 refactor(core): reorganize superset-core packages into feature-based structure (#38448) 2026-03-05 17:41:15 -03:00
Michael S. Molina
c41942a38a chore(deps): Upgrade sqlglot from 27.15.2 to 28.10.0 (#37841) 2026-02-10 13:13:11 -03:00
Amin Ghadersohi
15b3c96f8e fix(security): Add table blocklist and fix MCP SQL validation bypass (#37411) 2026-02-09 14:12:06 +01:00
Evan Rusackas
87bbd54d0a feat(examples): Transpile virtual dataset SQL on import (#37311)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
Co-authored-by: bito-code-review[bot] <188872107+bito-code-review[bot]@users.noreply.github.com>
2026-01-22 09:50:05 -08:00
ankitajhanwar2001
d8f7ae83ee fix(sqlglot): use Athena dialect for awsathena parsing (#36747) 2026-01-12 10:06:46 -08:00
Michael S. Molina
28e3ba749e feat: SQL execution API for Superset (#36529)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-16 14:39:29 -03:00
Evan Rusackas
c7a4d4f2cc fix(sql): handle backtick-quoted identifiers with base dialect (#36545)
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-15 13:00:13 -08:00
Beto Dealmeida
e4cb84bc02 feat: DB2 dialect for sqlglot (#36365) 2025-12-02 12:19:52 -05:00
amaannawab923
186693b840 feat(ag-grid): add SQLGlot-based SQL escaping for where and having filter clauses (#36136) 2025-11-25 09:35:40 +02:00
Beto Dealmeida
f3e620cd0f fix: RLS in virtual datasets (#36061) 2025-11-14 14:21:09 -05:00
Vitor Avila
6701d0ae0c fix: Use singlestoredb dialect for sqlglot (#36096) 2025-11-13 16:10:55 -03:00
Beto Dealmeida
62dc5c0306 fix(cache): ensure SQL is sanitized before cache key generation (#35419) 2025-10-02 13:25:54 -04:00
Beto Dealmeida
3202ff4b3f fix(pinot): more functions (#35451) 2025-10-02 13:01:47 -04:00
Beto Dealmeida
30021f8ede fix(pinot): SUBSTR function (#35427) 2025-10-02 10:29:18 -04:00
Beto Dealmeida
f3349388d0 fix(pinot): DATE_SUB function (#35426) 2025-10-02 10:12:19 -04:00
Beto Dealmeida
5428376662 fix(pinot): DATE_ADD function (#35424) 2025-10-02 09:56:20 -04:00