john-bodley commented on code in PR #25147:
URL: https://github.com/apache/superset/pull/25147#discussion_r1364911415


##########
superset/common/query_object_factory.py:
##########
@@ -102,3 +113,54 @@ def _process_row_limit(
     # light version of the view.utils.core
     # import view.utils require application context
     # Todo: move it and the view.utils.core to utils package
+
+    def _process_filters(
+        self, datasource: BaseDatasource, query_filters: 
list[QueryObjectFilterClause]
+    ) -> list[QueryObjectFilterClause]:
+        def get_dttm_filter_value(
+            value: Any, col: BaseColumn, date_format: str
+        ) -> int | str:
+            if not isinstance(value, int):
+                return value
+            if date_format in {"epoch_ms", "epoch_s"}:
+                if date_format == "epoch_s":
+                    value = str(value)
+                else:
+                    value = str(value * 1000)
+            else:
+                dttm = datetime.utcfromtimestamp(value / 1000)
+                value = dttm.strftime(date_format)
+
+            if col.type in col.num_types:
+                value = int(value)
+            return value
+
+        for query_filter in query_filters:
+            if query_filter.get("op") == FilterOperator.TEMPORAL_RANGE:

Review Comment:
   BTW, rather than the continue I think one if statement (based on truthiness 
and not falseness) is likely more readable. i.e., 
   
   ```python
   if (
       query_filter.get("op") != FilterOperator.TEMPORAL_RANGE
       and (filter_col := query_filter.get("col"))
       and isinstance(filter_col, str)
       and (column := datasource.get_column(filter_col))
    ):
        ...
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to