mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
feat: add support for comments in adhoc clauses (#19248)
* feat: add support for comments in adhoc clauses * sanitize remaining freeform clauses * sanitize adhoc having in frontend * address review comment
This commit is contained in:
@@ -98,6 +98,7 @@ from superset.exceptions import (
|
||||
SupersetException,
|
||||
SupersetTimeoutException,
|
||||
)
|
||||
from superset.sql_parse import sanitize_clause
|
||||
from superset.superset_typing import (
|
||||
AdhocColumn,
|
||||
AdhocMetric,
|
||||
@@ -1366,10 +1367,12 @@ def split_adhoc_filters_into_base_filters( # pylint: disable=invalid-name
|
||||
}
|
||||
)
|
||||
elif expression_type == "SQL":
|
||||
sql_expression = adhoc_filter.get("sqlExpression")
|
||||
sql_expression = sanitize_clause(sql_expression)
|
||||
if clause == "WHERE":
|
||||
sql_where_filters.append(adhoc_filter.get("sqlExpression"))
|
||||
sql_where_filters.append(sql_expression)
|
||||
elif clause == "HAVING":
|
||||
sql_having_filters.append(adhoc_filter.get("sqlExpression"))
|
||||
sql_having_filters.append(sql_expression)
|
||||
form_data["where"] = " AND ".join(
|
||||
["({})".format(sql) for sql in sql_where_filters]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user