joe-clickhouse commented on code in PR #34091:
URL: https://github.com/apache/superset/pull/34091#discussion_r2519450229
##########
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:
Will fix.
--
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]