You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2022/11/28 10:48:13 UTC

[superset] branch master updated: fix(generic-chart-axes): apply time filter on all target column types (#22238)

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 940a17514f fix(generic-chart-axes): apply time filter on all target column types (#22238)
940a17514f is described below

commit 940a17514fcb933e0c44364767eab5db40d3d20e
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Mon Nov 28 12:47:55 2022 +0200

    fix(generic-chart-axes): apply time filter on all target column types (#22238)
    
    Co-authored-by: Ville Brofeldt <vi...@apple.com>
---
 superset/connectors/base/models.py | 3 +++
 superset/connectors/sqla/models.py | 1 +
 superset/models/helpers.py         | 4 ++++
 3 files changed, 8 insertions(+)

diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py
index 1c9696083b..b127229328 100644
--- a/superset/connectors/base/models.py
+++ b/superset/connectors/base/models.py
@@ -395,6 +395,7 @@ class BaseDatasource(
     @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 @@ class BaseDatasource(
             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 0b62f09862..a67e686ff3 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -1415,6 +1415,7 @@ class SqlaTable(Model, BaseDatasource):  # pylint: disable=too-many-public-metho
                     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 1aa195fed2..2582f7e8d2 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -1095,6 +1095,7 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
     @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 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
             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 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
                     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,