mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
fix: add suffix to Drill labels to avoid collision (#32857)
Co-authored-by: Fredrik Hyyrynen <fredrik.hyyrynen@ngm.se> Co-authored-by: Evan Rusackas <evan@rusackas.com> Co-authored-by: pre-commit <pre-commit@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,7 @@ from sqlalchemy.engine.url import URL
|
||||
from superset.constants import TimeGrain
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.db_engine_specs.exceptions import SupersetDBAPIProgrammingError
|
||||
from superset.utils.hashing import md5_sha_from_str
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from superset.models.core import Database
|
||||
@@ -143,3 +144,14 @@ class DrillEngineSpec(BaseEngineSpec):
|
||||
if str(ex) == "generator raised StopIteration":
|
||||
return []
|
||||
raise
|
||||
|
||||
@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
|
||||
|
||||
:param label: Expected expression label
|
||||
:return: Conditionally mutated label
|
||||
"""
|
||||
return f"{label}_{md5_sha_from_str(label)[:6]}"
|
||||
|
||||
Reference in New Issue
Block a user