diff --git a/superset/sql/parse.py b/superset/sql/parse.py index 055aa3caaac..09a6cfe49e5 100644 --- a/superset/sql/parse.py +++ b/superset/sql/parse.py @@ -33,6 +33,7 @@ from sqlglot.dialects.dialect import ( Dialect, Dialects, ) +from sqlglot.dialects.singlestore import SingleStore from sqlglot.errors import ParseError from sqlglot.optimizer.pushdown_predicates import ( pushdown_predicates, @@ -101,7 +102,7 @@ SQLGLOT_DIALECTS = { "redshift": Dialects.REDSHIFT, "risingwave": Dialects.RISINGWAVE, "shillelagh": Dialects.SQLITE, - "singlestore": Dialects.MYSQL, + "singlestoredb": SingleStore, "snowflake": Dialects.SNOWFLAKE, # "solr": ??? "spark": Dialects.SPARK, diff --git a/tests/unit_tests/sql/parse_tests.py b/tests/unit_tests/sql/parse_tests.py index 8678c25ffa3..6d89a3356e8 100644 --- a/tests/unit_tests/sql/parse_tests.py +++ b/tests/unit_tests/sql/parse_tests.py @@ -2803,6 +2803,19 @@ def test_kqlstatement_is_select(kql: str, expected: bool) -> None: assert KustoKQLStatement(kql, "kustokql").is_select() == expected +def test_singlestore_engine_mapping(): + """ + Test the `singlestoredb` dialect is properly used. + """ + sql = "SELECT COUNT(*) AS `COUNT(*)`" + statement = SQLStatement(sql, engine="singlestoredb") + assert statement.is_select() + + # Should parse without errors + formatted = statement.format() + assert "COUNT(*)" in formatted + + def test_remove_quotes() -> None: """ Test the `remove_quotes` helper function.