-
Notifications
You must be signed in to change notification settings - Fork 4
Description
We decided on using Uppercase names for entities, so we have attributes like Business Region. If such an Attribute is added with a Prefix, we get Prefix business Region because mara_schema.attributes.Attribute.prefixed_name(...) will lowercase the first char in a name if and all path elements if it is prefixed: https://github.com/mara/mara-schema/blob/master/mara_schema/attribute.py#L54-L55
It would be nice if this could be configured/patchable. I'm currently patching the whole prefixed_name() function but because this is a method and not a function, the normal @patch() doesn't work :-(
# Overwrite the lowercasing of entity names after a prefix
# Can't use patch, but simply assigning works :-)
def _prefixed_name(self, path: t.Tuple['EntityLink'] = None) -> str:
"""Generate a meaningful business name by concatenating the prefix of entity link instances and original
name of attribute. """
from mara_schema.attribute import normalize_name
if path:
prefix = ' '.join([entity_link.prefix for entity_link in path])
return normalize_name(prefix + ' ' + self.name)
else:
return normalize_name(self.name)
mara_schema.attribute.Attribute.prefixed_name = _prefixed_name(BTW: seeing this, if would be nice if there could be a best practise guide for namings, so that this doesn't show up later. Especially because metabase has a bug (metabase/metabase#7923 (comment)) which does not allow for renaming only the casing of an already ingested column, which totally screws up the schema sync in mara-metabase in such cases :-()