From fa7b66424cf78a789c3d3134c11da4335e0365a7 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Thu, 21 Nov 2024 11:08:53 -0500 Subject: [PATCH] chore: add unit tests for `is_mutating()` (#31021) --- tests/unit_tests/sql/parse_tests.py | 71 ++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/sql/parse_tests.py b/tests/unit_tests/sql/parse_tests.py index ada6314457fbc..726e2294e29ea 100644 --- a/tests/unit_tests/sql/parse_tests.py +++ b/tests/unit_tests/sql/parse_tests.py @@ -901,7 +901,6 @@ def test_split_kql() -> None: @pytest.mark.parametrize( ("engine", "sql", "expected"), [ - # SQLite tests ("sqlite", "SELECT 1", False), ("sqlite", "INSERT INTO foo VALUES (1)", True), ("sqlite", "UPDATE foo SET bar = 2 WHERE id = 1", True), @@ -979,3 +978,73 @@ def test_custom_dialect(app: None) -> None: Test that custom dialects are loaded correctly. """ assert SQLGLOT_DIALECTS.get("custom") == Dialects.MYSQL + + +@pytest.mark.parametrize( + "engine", + [ + "ascend", + "awsathena", + "base", + "bigquery", + "clickhouse", + "clickhousedb", + "cockroachdb", + "couchbase", + "crate", + "databend", + "databricks", + "db2", + "denodo", + "dremio", + "drill", + "druid", + "duckdb", + "dynamodb", + "elasticsearch", + "exa", + "firebird", + "firebolt", + "gsheets", + "hana", + "hive", + "ibmi", + "impala", + "kustokql", + "kustosql", + "kylin", + "mariadb", + "motherduck", + "mssql", + "mysql", + "netezza", + "oceanbase", + "ocient", + "odelasticsearch", + "oracle", + "pinot", + "postgresql", + "presto", + "pydoris", + "redshift", + "risingwave", + "rockset", + "shillelagh", + "snowflake", + "solr", + "sqlite", + "starrocks", + "superset", + "teradatasql", + "trino", + "vertica", + ], +) +def test_is_mutating(engine: str) -> None: + """ + Tests for `is_mutating`. + """ + assert not SQLStatement( + "with source as ( select 1 as one ) select * from source", + engine=engine, + ).is_mutating()