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:
Shaitan
2026-06-02 21:50:27 +01:00
committed by GitHub
parent 3e589436fa
commit 6eaee211aa
8 changed files with 441 additions and 46 deletions

View File

@@ -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",
[