mirror of
https://github.com/apache/superset.git
synced 2026-04-21 09:04:38 +00:00
fix(cache): ensure SQL is sanitized before cache key generation (#35419)
This commit is contained in:
@@ -1482,6 +1482,15 @@ def sanitize_clause(clause: str, engine: str) -> str:
|
||||
Make sure the SQL clause is valid.
|
||||
"""
|
||||
try:
|
||||
return SQLStatement(clause, engine).format()
|
||||
statement = SQLStatement(clause, engine)
|
||||
dialect = SQLGLOT_DIALECTS.get(engine)
|
||||
from sqlglot.dialects.dialect import Dialect
|
||||
|
||||
return Dialect.get_or_raise(dialect).generate(
|
||||
statement._parsed, # pylint: disable=protected-access
|
||||
copy=True,
|
||||
comments=False,
|
||||
pretty=False,
|
||||
)
|
||||
except SupersetParseError as ex:
|
||||
raise QueryClauseValidationException(f"Invalid SQL clause: {clause}") from ex
|
||||
|
||||
Reference in New Issue
Block a user