fix(api,sql): use json_response in Api.query and log dialect fallback (#40644)

Co-authored-by: Claude Code <noreply@anthropic.com>
This commit is contained in:
Evan Rusackas
2026-06-02 11:48:46 -07:00
committed by GitHub
parent 4d2b10d916
commit b97d3ef520
4 changed files with 60 additions and 1 deletions

View File

@@ -17,6 +17,8 @@
# pylint: disable=invalid-name, redefined-outer-name, too-many-lines
import logging
import pytest
from pytest_mock import MockerFixture
from sqlglot import Dialects, exp, parse_one
@@ -3311,3 +3313,21 @@ def test_backtick_invalid_sql_still_fails() -> None:
sql = "SELECT * FROM `table` WHERE"
with pytest.raises(SupersetParseError):
SQLScript(sql, "base")
def test_backtick_fallback_logs_warning(caplog: pytest.LogCaptureFixture) -> None:
"""
Test that the MySQL dialect fallback emits a warning log.
When the base dialect fails to parse SQL containing backticks and the
parser falls back to the MySQL dialect, the fallback should be observable
via a warning log.
"""
sql = "SELECT * FROM `my_table`"
with caplog.at_level(logging.WARNING, logger="superset.sql.parse"):
SQLScript(sql, "base")
assert any(
record.levelname == "WARNING" and "MySQL dialect" in record.getMessage()
for record in caplog.records
)