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



##########
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:
       This is about adding quotes around the labels, e.g. 
   
   ```
   Duplicate labels:  Population of Canada, Population of USA, Time.
   ```
   
   v.s.
   
   ```
   Duplicate labels: "Population of Canada", "Population of USA", "Time".
   ```
   
   Can `TypeVar` support that?




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