villebro commented on a change in pull request #10270:
URL: https://github.com/apache/superset/pull/10270#discussion_r564392381



##########
File path: superset/common/query_object.py
##########
@@ -214,8 +223,34 @@ def __init__(
 
     @property
     def metric_names(self) -> List[str]:
+        """Return metrics names (labels), coerce adhoc metrics to strings."""
         return get_metric_names(self.metrics)
 
+    @property
+    def column_names(self) -> List[str]:
+        """Return column names (labels). Reserved for future adhoc calculated
+        columns."""
+        return self.columns
+
+    def validate(
+        self, raise_exceptions: Optional[bool] = True
+    ) -> Optional[QueryObjectValidationError]:
+        """Validate query object"""
+        error: Optional[QueryObjectValidationError] = None
+        all_labels = self.metric_names + self.column_names
+        if len(set(all_labels)) < len(all_labels):
+            dup_labels = find_duplicates(all_labels)
+            error = QueryObjectValidationError(
+                _(
+                    "Duplicate column/metric labels: %(labels)s. Please make "
+                    "sure all columns and metrics have a unique label.",
+                    labels=", ".join(map(lambda x: f'"{x}"', dup_labels)),

Review comment:
       Oh right, I missed that - It's customary to use a list comprehension 
here, so I'd rather just do 
   ```python
                       labels=", ".join([f'"{label}"' for label in dup_labels]),
   ```
   to keep it in line with conventions used elsewhere in the codebase.




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

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