Skip to content

Commit

Permalink
Another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Nov 24, 2024
1 parent 8e0c00a commit 782f94f
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions tests/unit_tests/db_engine_specs/test_kusto.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,26 @@
@pytest.mark.parametrize(
"sql,expected",
[
("SELECT foo FROM tbl", True),
("SELECT foo FROM tbl", False),
("SHOW TABLES", False),
("EXPLAIN SELECT foo FROM tbl", False),
("INSERT INTO tbl (foo) VALUES (1)", False),
("INSERT INTO tbl (foo) VALUES (1)", True),
],
)
def test_sql_is_readonly_query(sql: str, expected: bool) -> None:
def test_sql_has_mutation(sql: str, expected: bool) -> None:
"""
Make sure that SQL dialect consider only SELECT statements as read-only
"""

from superset.db_engine_specs.kusto import KustoSqlEngineSpec

is_readonly = SQLScript(
sql,
engine=KustoSqlEngineSpec.engine,
).has_mutation()

assert expected == is_readonly
assert (
SQLScript(
sql,
engine=KustoSqlEngineSpec.engine,
).has_mutation()
== expected
)


@pytest.mark.parametrize(
Expand All @@ -67,36 +68,35 @@ def test_kql_is_select_query(kql: str, expected: bool) -> None:
from superset.db_engine_specs.kusto import KustoKqlEngineSpec

parsed_query = ParsedQuery(kql)
is_select = KustoKqlEngineSpec.is_select_query(parsed_query)

assert expected == is_select
assert KustoKqlEngineSpec.is_select_query(parsed_query) == expected


@pytest.mark.parametrize(
"kql,expected",
[
("tbl | limit 100", True),
("let foo = 1; tbl | where bar == foo", True),
(".show tables", True),
("print 1", True),
("set querytrace; Events | take 100", True),
(".drop table foo", False),
(".set-or-append table foo <| bar", False),
("tbl | limit 100", False),
("let foo = 1; tbl | where bar == foo", False),
(".show tables", False),
("print 1", False),
("set querytrace; Events | take 100", False),
(".drop table foo", True),
(".set-or-append table foo <| bar", True),
],
)
def test_kql_is_readonly_query(kql: str, expected: bool) -> None:
def test_kql_has_mutation(kql: str, expected: bool) -> None:
"""
Make sure that KQL dialect consider only SELECT statements as read-only
"""

from superset.db_engine_specs.kusto import KustoKqlEngineSpec

is_readonly = SQLScript(
kql,
engine=KustoKqlEngineSpec.engine,
).has_mutation()

assert expected == is_readonly
assert (
SQLScript(
kql,
engine=KustoKqlEngineSpec.engine,
).has_mutation()
== expected
)


def test_kql_parse_sql() -> None:
Expand Down

0 comments on commit 782f94f

Please sign in to comment.