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

Ct-65 metrics names with spaces #5173

Merged
merged 5 commits into from Apr 27, 2022
Merged

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Apr 27, 2022

resolves #4572

Description

Adds validation to UnparsedMetric class to ensure the metric name does not contain spaces

Checklist

@gshank gshank requested review from a team as code owners April 27, 2022 00:20
@cla-bot cla-bot bot added the cla:yes label Apr 27, 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.

Copy link
Member

@emmyoop emmyoop left a comment

Choose a reason for hiding this comment

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

LGTM

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 converting the test as well :)

@classmethod
def validate(cls, data):
super(UnparsedMetric, cls).validate(data)
if "name" in data and " " in data["name"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

In #4572, Joel offers:

  • Motivation: Using metric names as column names. This will indeed vary by database!
  • Expectation: [_A-Za-z] (I might say [a-z0-9_], as long as the numeric digit isn't first)

IMO spaces are the most disagreeable, even more than special characters. In any case, it looks like the logic here will be easy to extend if we decide to limit valid metric names to, e.g., alphanumeric characters and underscores. We'll want to incorporate opinions from the future maintainer(s) of the dbt-metrics package. For now, I'm happy with what you've got here!

@gshank gshank merged commit 4e57c51 into main Apr 27, 2022
@gshank gshank deleted the ct-65-metrics_names_with_spaces branch April 27, 2022 14:57
agoblet pushed a commit to BigDataRepublic/dbt-core that referenced this pull request May 20, 2022
* Convert existing metrics test

* add non-failing test for names with spaces

* Raise ParsingException if metrics name contains spaces

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

Successfully merging this pull request may close these issues.

[CT-65] [Bug] Metrics' names shouldn’t be allowed to contain spaces
3 participants