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

Begin Validating Metric Names #184

Merged
merged 4 commits into from
Oct 25, 2023
Merged

Conversation

QMalcolm
Copy link
Collaborator

Resolves #181

Description

We've been saying that we require metric names to match the regex (must start with a letter, must be lower case, can't contain dunders, and etc), but we haven't actually been validating this. This PR updates the UniqueAndValidNameRule to actually begin validating metric names. It's worth noting that we plan on backporting this to 0.3.latest as not validating the name doesn't cause issues in this repo, but will cause issues in the semantic layer.

Checklist

@QMalcolm QMalcolm added the Backport 0.3.latest Fix should be backported to 0.3.latest label Oct 23, 2023
@QMalcolm QMalcolm requested review from tlento and plypaul October 23, 2023 17:43
@cla-bot cla-bot bot added the cla:yes label Oct 23, 2023
@QMalcolm
Copy link
Collaborator Author

@Jstein77 It's worth noting that we may need some messaging around this as people could have specified invalid names in DSI 0.2.x (used by dbt-core 1.6.x). I've checked the fivetran dbt_add_reporting package, and it appears that this change won't cause any issues for that package.

@QMalcolm QMalcolm mentioned this pull request Oct 23, 2023
4 tasks
@QMalcolm
Copy link
Collaborator Author

This is a stacked PR

@QMalcolm QMalcolm removed the Backport 0.3.latest Fix should be backported to 0.3.latest label Oct 25, 2023
Copy link
Collaborator

@tlento tlento left a comment

Choose a reason for hiding this comment

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

Seems reasonable! As discussed let's mark this as a breaking change.

@@ -0,0 +1,6 @@
kind: Fixes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update to breaking change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Corrected in: e376244
Will be fixed up into: f0b1389

@@ -0,0 +1,6 @@
kind: Fixes
body: Actually validate metric names like we say we do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indicate it's a fix here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Corrected in: e376244
Will be fixed up into: f0b1389

Comment on lines 47 to 48
compied_manifest = deepcopy(simple_semantic_manifest__with_primary_transforms)
semantic_model = compied_manifest.semantic_models[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: compied -> copied

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Corrected in: 98e21d0
Will be fixed up into: bd56473

Comment on lines 84 to 85
compied_manifest = deepcopy(simple_semantic_manifest__with_primary_transforms)
metric = compied_manifest.metrics[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

compied copied compied copied. 😛

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Corrected in: b99cc42
Will be fixed up into: f0b1389

@QMalcolm
Copy link
Collaborator Author

Rebasing to fixup changes into relevant commits as noted in comments

We used to have more types of top level objects, and we required
uniqueness in their names across them. However the top level objects
which required this are gone. Uniqueness is now only required for
top level objects within their object type. This allows us to remove
old logic and make the validating of semantic model names look the same
as how we validate metric names. In our next commit, we'll abstract
these duplicate implementations now that they look the same.
…er function

We were doing a bunch of duplicate logic in `_validate_top_level_objects` that
could be abstracted out. Unfortunately abstracting it out required generating
the contexts for validatin issues in advance. It's not the prettiest, but it
was necessary. Ideally the context building should happen in the helper method
itself, however this isn't currently possible. We'd either need to have a
generic context, be able to identify which context needs to be built, or have
a generalized context class.
@QMalcolm QMalcolm force-pushed the qmalcolm--181-validate-metric-names branch from b99cc42 to 54a0648 Compare October 25, 2023 23:23
@QMalcolm QMalcolm merged commit 099b916 into main Oct 25, 2023
9 checks passed
@QMalcolm QMalcolm deleted the qmalcolm--181-validate-metric-names branch October 25, 2023 23:35
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.

[Bug] Metric names aren't run through name regex
2 participants