mirror of
https://github.com/apache/superset.git
synced 2026-07-19 13:15:49 +00:00
fix(sqllab): require dataset match for raw query access (#40409)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1166,6 +1166,30 @@ def test_has_mutation(engine: str, sql: str, expected: bool) -> None:
|
||||
assert SQLScript(sql, engine).has_mutation() == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"engine, sql, expected",
|
||||
[
|
||||
# Plain SELECT parses to a proper AST node.
|
||||
("postgresql", "SELECT * FROM foo", False),
|
||||
# CALL parses to ``exp.Command`` on Postgres.
|
||||
("postgresql", "CALL my_proc(1);", True),
|
||||
# A script that mixes a parseable statement with an unparseable one
|
||||
# is still flagged so strict scoping can refuse the whole script.
|
||||
("postgresql", "SELECT 1; CALL my_proc();", True),
|
||||
# Non-sqlglot engines (e.g. Kusto KQL) do not produce a parseable
|
||||
# AST and cannot have their tables enumerated, so they must be
|
||||
# flagged as unparseable to fail closed under strict scoping.
|
||||
("kustokql", "print 1", True),
|
||||
],
|
||||
)
|
||||
def test_has_unparseable_statement(engine: str, sql: str, expected: bool) -> None:
|
||||
"""
|
||||
Test the `has_unparseable_statement` property used by strict scoping to
|
||||
refuse statements that sqlglot couldn't fully model.
|
||||
"""
|
||||
assert SQLScript(sql, engine).has_unparseable_statement is expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sql",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user