-
Notifications
You must be signed in to change notification settings - Fork 97
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
Allow custom granularity names in string name to struct conversion #1387
Allow custom granularity names in string name to struct conversion #1387
Conversation
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. |
ea0ee4f
to
c8ca0af
Compare
|
||
This implies that all values in the TimeGranularity enumeration must be lower-case. | ||
""" | ||
assert self.element_name.lower() == self.element_name, ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that custom granularities will be required to be lowercase. Is that a necessary restriction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, yes. We do not want Fortnight
and fortnight
to mean different things in the same model. But also this this the standard we've used for ages.
"parse time!" | ||
) | ||
assert all([link_name.lower() == link_name for link_name in self.entity_link_names]), ( | ||
f"Found entity link name that includes upper-case letters. Entity link names: {self.entity_link_names}. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this enforced already? That entity names must be lowercase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! And a helpful link pointing me to how to add this validation for custom granularities too 🙃
c8ca0af
to
dafccd5
Compare
MetricFlow relies on a class called StructuredLinkableSpecName to manage conversion between structured names and their string representations, e.g., `listing__is_lux` or `listing__created_at__month`. Up until now the time granularity component of this naming struct required an enumeration value, which would then be converted to its string representation at serialization time. With custom granularities we need to explicitly allow for a string name for the input time granularity. This implements that change, along with some added enforcement to ensure consistency in how we conver to/from the string representations of these names.
dafccd5
to
1b2bbeb
Compare
MetricFlow relies on a class called StructuredLinkableSpecName to manage
conversion between structured names and their string representations,
e.g.,
listing__is_lux
orlisting__created_at__month
.Up until now the time granularity component of this naming struct
required an enumeration value, which would then be converted to its
string representation at serialization time. With custom granularities
we need to explicitly allow for a string name for the input time
granularity. This implements that change, along with some added
enforcement to ensure consistency in how we conver to/from the string
representations of these names.