Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad assumption with prefixed attributes: attributes only have the first char as uppercase #11

Open
jankatins opened this issue Feb 22, 2021 · 0 comments

Comments

@jankatins
Copy link
Member

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 :-()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant