villebro commented on code in PR #21378:
URL: https://github.com/apache/superset/pull/21378#discussion_r970841998


##########
superset/utils/core.py:
##########
@@ -1271,15 +1271,15 @@ def is_adhoc_column(column: Column) -> 
TypeGuard[AdhocColumn]:
     return isinstance(column, dict)
 
 
-def get_base_axis_column(columns: Optional[List[Column]]) -> 
Optional[AdhocColumn]:
-    if columns is None:
-        return None
+def get_base_axis_label(columns: Optional[List[Column]]) -> Optional[str]:

Review Comment:
   Could this be:
   ```python
   def get_base_axis_labels(columns: Optional[List[Column]]) -> List[str]:
   ```
   i.e. an empty list if there are none, and otherwise all axis column labels?



##########
superset/common/query_context_processor.py:
##########
@@ -245,11 +246,21 @@ def normalize_df(self, df: pd.DataFrame, query_object: 
QueryObject) -> pd.DataFr
             if dttm_col:
                 timestamp_format = dttm_col.python_date_format
 
+        base_axis_label = None
+        if (
+            (label := get_base_axis_label(query_object.columns))
+            and query_object.datasource is not None
+            and (base_column := query_object.datasource.get_column(label))
+            and base_column.is_dttm
+        ):
+            base_axis_label = label
+
         normalize_dttm_col(
             df=df,
             timestamp_format=timestamp_format,
             offset=datasource.offset,
             time_shift=query_object.time_shift,
+            dttm_alias=base_axis_label,

Review Comment:
   In reference to my comment about changing `get_base_axis_label` to plural 
form, could we loop through all `base_axis_labels` here to future proof for 
multi-dimensional charts?



##########
superset/utils/core.py:
##########
@@ -1850,28 +1853,31 @@ def normalize_dttm_col(
     timestamp_format: Optional[str],
     offset: int,
     time_shift: Optional[timedelta],
+    dttm_alias: Optional[str] = DTTM_ALIAS,

Review Comment:
   nit: could we call this `dttm_col` to be more in line with the method name?



-- 
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