This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 1014a327f5 fix(sqla): copy temporal range logic to helper (#22405)
1014a327f5 is described below
commit 1014a327f5ed2e1e4f1daec283825e94c7640d05
Author: Ville Brofeldt <[email protected]>
AuthorDate: Wed Dec 14 09:43:38 2022 +0200
fix(sqla): copy temporal range logic to helper (#22405)
Co-authored-by: Ville Brofeldt <[email protected]>
---
superset/models/helpers.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 2582f7e8d2..8931ba3af6 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -65,6 +65,7 @@ from sqlalchemy_utils import UUIDType
from superset import app, is_feature_enabled, security_manager
from superset.advanced_data_type.types import AdvancedDataTypeResponse
from superset.common.db_query_status import QueryStatus
+from superset.common.utils.time_range_utils import
get_since_until_from_time_range
from superset.constants import EMPTY_STRING, NULL_STRING
from superset.db_engine_specs.base import TimestampExpression
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
@@ -1236,8 +1237,8 @@ class ExploreMixin: # pylint:
disable=too-many-public-methods
def get_time_filter(
self,
time_col: Dict[str, Any],
- start_dttm: sa.DateTime,
- end_dttm: sa.DateTime,
+ start_dttm: Optional[sa.DateTime],
+ end_dttm: Optional[sa.DateTime],
) -> ColumnElement:
label = "__time"
col = time_col.get("column_name")
@@ -1779,6 +1780,23 @@ class ExploreMixin: # pylint:
disable=too-many-public-methods
where_clause_and.append(sqla_col.like(eq))
elif op == utils.FilterOperator.ILIKE.value:
where_clause_and.append(sqla_col.ilike(eq))
+ elif (
+ op == utils.FilterOperator.TEMPORAL_RANGE.value
+ and isinstance(eq, str)
+ and col_obj is not None
+ ):
+ _since, _until = get_since_until_from_time_range(
+ time_range=eq,
+ time_shift=time_shift,
+ extras=extras,
+ )
+ where_clause_and.append(
+ self.get_time_filter(
+ time_col=col_obj,
+ start_dttm=_since,
+ end_dttm=_until,
+ )
+ )
else:
raise QueryObjectValidationError(
_("Invalid filter operation type: %(op)s", op=op)