bito-code-review[bot] commented on code in PR #37396:
URL: https://github.com/apache/superset/pull/37396#discussion_r2763903858


##########
superset/utils/core.py:
##########
@@ -1756,6 +1756,42 @@ def extract_dataframe_dtypes(
     return generic_types
 
 
+def extract_display_labels(
+    label_map: dict[str, list[str]],
+    colnames: list[str],
+    datasource: Explorable | None = None,
+) -> list[str]:
+    """Extract display labels for a list of column names based on a label map
+    and an optional datasource.
+    """
+    if not colnames:
+        return []
+
+    # Build column -> label mapping (skip self-references)
+    columns_to_label = {}
+    if label_map:
+        for label, cols in label_map.items():
+            for col in cols:
+                if label != col and col not in columns_to_label:
+                    columns_to_label[col] = label
+
+    # Build column -> object mapping
+    columns_by_name: dict[str, Any] = {}
+    if datasource:
+        for column in datasource.columns:
+            if isinstance(column, dict):
+                if column_name := column.get("column_name"):
+                    columns_by_name[column_name] = column
+            else:
+                columns_by_name[column.column_name] = column
+
+    return [
+        columns_to_label.get(col)
+        or (get_column_name(columns_by_name[col]) if col in columns_by_name 
else col)

Review Comment:
   <!-- Bito Reply -->
   The suggestion recommends modifying `extract_display_labels` to handle dict 
columns more tolerantly and avoid a potential ValueError from 
`get_column_name`. However, since other usages in the codebase omit error 
handling and you believe the error can't realistically occur, applying this 
change may not be necessary and could introduce unnecessary complexity.



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