diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py index 1c9696083bedc..b1272293286d9 100644 --- a/superset/connectors/base/models.py +++ b/superset/connectors/base/models.py @@ -395,6 +395,7 @@ def data_for_slices( # pylint: disable=too-many-locals @staticmethod def filter_values_handler( # pylint: disable=too-many-arguments values: Optional[FilterValues], + operator: str, target_generic_type: GenericDataType, target_native_type: Optional[str] = None, is_list_target: bool = False, @@ -405,6 +406,8 @@ def filter_values_handler( # pylint: disable=too-many-arguments return None def handle_single_value(value: Optional[FilterValue]) -> Optional[FilterValue]: + if operator == utils.FilterOperator.TEMPORAL_RANGE: + return value if ( isinstance(value, (float, int)) and target_generic_type == utils.GenericDataType.TEMPORAL diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 0b62f0986264c..a67e686ff31f0 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -1415,6 +1415,7 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma target_generic_type = GenericDataType.STRING eq = self.filter_values_handler( values=val, + operator=op, target_generic_type=target_generic_type, target_native_type=col_type, is_list_target=is_list_target, diff --git a/superset/models/helpers.py b/superset/models/helpers.py index 1aa195fed22f4..2582f7e8d2b60 100644 --- a/superset/models/helpers.py +++ b/superset/models/helpers.py @@ -1095,6 +1095,7 @@ def template_params_dict(self) -> Dict[Any, Any]: @staticmethod def filter_values_handler( # pylint: disable=too-many-arguments values: Optional[FilterValues], + operator: str, target_generic_type: utils.GenericDataType, target_native_type: Optional[str] = None, is_list_target: bool = False, @@ -1107,6 +1108,8 @@ def filter_values_handler( # pylint: disable=too-many-arguments return None def handle_single_value(value: Optional[FilterValue]) -> Optional[FilterValue]: + if operator == utils.FilterOperator.TEMPORAL_RANGE: + return value if ( isinstance(value, (float, int)) and target_generic_type == utils.GenericDataType.TEMPORAL @@ -1692,6 +1695,7 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma target_generic_type = utils.GenericDataType.STRING eq = self.filter_values_handler( values=val, + operator=op, target_generic_type=target_generic_type, target_native_type=col_type, is_list_target=is_list_target,