mirror of
https://github.com/apache/superset.git
synced 2026-07-12 17:55:38 +00:00
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:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user