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

Validate exposure names and add label #5844

Merged
merged 7 commits into from
Sep 21, 2022

Conversation

emmyoop
Copy link
Member

@emmyoop emmyoop commented Sep 14, 2022

resolves #5606

Description

Adds label and name validation for exposures. Kept as a separate PR to keep the label addition with the name validation.

Open Question
Exactly what do we want to validate as a name? I just copied over from metrics but that's likely incorrect.

Checklist

@cla-bot cla-bot bot added the cla:yes label Sep 14, 2022
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@emmyoop emmyoop mentioned this pull request Sep 14, 2022
6 tasks
@@ -0,0 +1,7 @@
kind: Under the Hood
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where this falls in terms of changelog type?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might really be a Breaking Change - but I have an idea of how we could make it not one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're deprecating instead of erroring now, this won't be breaking. I'll leave as Under The Hood unless you disagree.

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @emmyoop! Sorry I missed your questions the other

As a follow-up to this, let's also start using label instead of name for identifying exposures in dbt-docs, similar to the changes in dbt-labs/dbt-docs#285

Comment on lines 457 to 460
if errors:
raise ParsingException(
f"Exposure name '{data['name']}' is invalid. It {', '.join(e for e in errors)}"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we actually make this deprecations.warn instead of ParsingException? I think there are many users (including this integration) who will be in violation of the new rule.

I can provide copy for the deprecation message, but the big idea is: "Hey! We just added support for a human-friendly label propertyon exposures. We see that {exposure} has some disallowed characters in its name — why not turn that into label, and then come up with a simpler name?"

Comment on lines 40 to 46
# todo: word this better - it's bad. Also do we want to set a timeline for when
# this will become an error?
_description = """\
Exposure names may not contain spaces and can only contain letters, numbers and underscores.
{exposure} does not follow this pattern. Please use the label attribute for more complex
names.
"""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtcohen6 please provide the promised wording 😄

Copy link
Contributor

@jtcohen6 jtcohen6 Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this:

    _description = """\
    Starting in v1.3, the 'name' of an exposure should contain only letters, numbers, and underscores.
    Exposures support a new property, 'label', which may contain spaces, capital letters, and special characters.
    {exposure} does not follow this pattern.
    Please update the 'name', and use the 'label' property for a human-friendly title.
    This will raise an error in a future version of dbt-core.
    """

In the case of metrics, we'd explicitly documented the metric spec as "experimental," and reserved the right to make breaking changes. In that context, it's nice for us to provide backward compatibility for one minor version, and reasonable to expect a quick turnaround (breaking change by v1.4).

Exposures have been around for longer, and without an "experimental" denotation — so I don't think we should commit to a quick turnaround for actual deprecation. The soonest I could see doing this is if we significantly expand the capabilities of exposures, as part of a potential initiative next year. Otherwise, in dbt v2.0.

Given that, I also don't feel the need to open an issue to track this. We'll have an opportunity to revisit this either when we reinvest in exposures, or when we revisit all of our deprecations ahead of v2 (just as we did ahead of v1).

@jtcohen6 jtcohen6 added the Refinement Maintainer input needed label Sep 20, 2022
@emmyoop emmyoop closed this Sep 20, 2022
@emmyoop emmyoop reopened this Sep 20, 2022
@emmyoop emmyoop force-pushed the er/ct-1184-exposure-name-validation-label branch from 3edbcb7 to 2a946fa Compare September 21, 2022 01:29
@emmyoop emmyoop marked this pull request as ready for review September 21, 2022 01:56
@emmyoop emmyoop requested review from a team as code owners September 21, 2022 01:56
@emmyoop emmyoop requested a review from gshank September 21, 2022 01:56
@emmyoop emmyoop force-pushed the er/ct-1184-exposure-name-validation-label branch from 2a946fa to 0f7a83e Compare September 21, 2022 14:36
@emmyoop emmyoop merged commit e402241 into main Sep 21, 2022
@emmyoop emmyoop deleted the er/ct-1184-exposure-name-validation-label branch September 21, 2022 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Refinement Maintainer input needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-1184] [Feature] Exposures: stricter validation for name, support custom label
3 participants