You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "emirkmo (via GitHub)" <gi...@apache.org> on 2024/01/22 14:11:33 UTC

Re: [PR] fix: Time Column on Generic X-axis [superset]

emirkmo commented on code in PR #23021:
URL: https://github.com/apache/superset/pull/23021#discussion_r1461918740


##########
superset/common/query_context_factory.py:
##########
@@ -99,3 +103,89 @@ def _convert_to_model(self, datasource: DatasourceDict) -> BaseDatasource:
 
     def _get_slice(self, slice_id: Any) -> Optional[Slice]:
         return ChartDAO.find_by_id(slice_id)
+
+    def _process_query_object(
+        self,
+        datasource: BaseDatasource,
+        form_data: Optional[Dict[str, Any]],
+        query_object: QueryObject,
+    ) -> QueryObject:
+        self._apply_granularity(query_object, form_data, datasource)
+        self._apply_filters(query_object)
+        return query_object
+
+    def _apply_granularity(
+        self,
+        query_object: QueryObject,
+        form_data: Optional[Dict[str, Any]],
+        datasource: BaseDatasource,
+    ) -> None:
+        temporal_columns = {
+            column.column_name
+            for column in datasource.columns
+            if (column["is_dttm"] if isinstance(column, dict) else column.is_dttm)
+        }
+        granularity = query_object.granularity
+        x_axis = form_data and form_data.get("x_axis")
+
+        if granularity:
+            filter_to_remove = None
+            if x_axis and x_axis in temporal_columns:

Review Comment:
   Is there an issue or PR linked to this?



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org