Copilot commented on code in PR #34091:
URL: https://github.com/apache/superset/pull/34091#discussion_r2505896526


##########
docs/docs/configuration/databases.mdx:
##########
@@ -359,6 +359,18 @@ uses the default user without a password (and doesn't 
encrypt the connection):
 clickhousedb://localhost/default
 ```
 
+Optional label alias mutation

Review Comment:
   Missing markdown header level. This should be formatted as a proper header 
(e.g., `##### Optional label alias mutation`) to maintain consistent 
documentation structure with the rest of the file.
   ```suggestion
   ##### Optional label alias mutation
   ```



##########
superset/db_engine_specs/clickhouse.py:
##########
@@ -411,13 +411,39 @@ def validate_parameters(
     @staticmethod
     def _mutate_label(label: str) -> str:
         """
-        Suffix with the first six characters from the md5 of the label to avoid
-        collisions with original column names
+        Conditionally suffix the label with the first six characters from the 
md5
+        of the label to avoid collisions with original column names.
+
+        By default, labels are mutated for backward compatibility. To disable 
this
+        behavior on a per-database basis, set `mutate_label_name` to `false` in
+        the database's "extra" JSON configuration:
+
+            {
+                "mutate_label_name": false
+            }
+
+        This is useful when your ClickHouse queries refer to their own aliases
+        within the same SELECT statement.
 
         :param label: Expected expression label
-        :return: Conditionally mutated label
+        :return: Mutated label if mutation is enabled, otherwise the original 
label
         """
-        return f"{label}_{md5_sha_from_str(label)[:6]}"
+        mutate_label = True
+
+        if hasattr(g, "database") and g.database:
+            try:
+                extra = g.database.get_extra()
+                mutate_label = extra.get("mutate_label_name", True)
+            except Exception:  # pylint: disable=broad-except
+                logger.warning(
+                    "Error retrieving mutate_label_name setting. Falling back 
to "
+                    "default behavior of True."
+                )
+                pass

Review Comment:
   The `pass` statement after the `logger.warning` call is unnecessary. The 
warning already handles the exception, so the `pass` can be removed.
   ```suggestion
   
   ```



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