-
Notifications
You must be signed in to change notification settings - Fork 94
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
Consolidate query interface params #717
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. |
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.
Added |
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.
Checkpoint review, I'm not quite done.
I'm not sold on the factory class pattern but I have nothing better to offer that will work with jinja, so this is probably one of those cases where it's better for us to proceed with minor readability updates and revisit if we need to.
That pattern isn't strictly necessary. It helps to ensure that all of the constructors in Jinja have the same interfaces. I think it is worth the added indirection for greater consistency, but I can remove it if you prefer. |
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.
Per our discussion, we are going to do the following here:
- Clean up the protocols a bit in some way in order to ensure there are property accessors for MetricFlow to use for building specs and so forth behind the API, and property configuration methods for the callers to implement so users can configure things on the client side
- Leave anything other than minor cleanup for follow-up PRs
- Figure out if we want to move to something like
group_by: Optional[Sequence[Union[str, NonAggregateParameter]]]
and, if so, have a separate PR where we get that all working nicely
I'm requesting changes just so I can get an alert when this is ready - please request review from me when you update. GitHub makes you do this manually, which always annoys me, but I haven't found a better mechanism.
I changed the factories to return individualized protocols instead of all sharing the Instead, I use |
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.
Looking much better, thank you!
I'm mildly concerned about the layers of indirection being confusing to readers of the future, particularly if they read by module instead of in coordination as these changes appear in this PR.
For now I think this is best addressed via documentation, and I've left a couple of minor pointers inline.
Unless you feel like you want another review pass you may update and merge at your convenience! This might merit a squash and merge operation, or at least a rebase -i and force push to clean up the history in this branch. It's a little gnarly commit-wise.
Thanks!
Resolves SLA-218 (internal to dbt Labs)
Description
This PR makes the
Dimension
,TimeDimension
, andEntity
objects that are passed into the where filter Jinja template implement protocols. These protocols allow for different implementations of these objects depending on the context (group_by
,where
,order_by
parameters) while also constraining these implementations to all have the same method signatures. This will create consistency across these contexts.The
Dimension
protocol is also implemented for parameters in certain methods (i.e.GroupByOrderByDimension
). This will allow for more complexDimension
objects in the future that aren't feasible to serialize into a string, such asDimension('demographic').grain('month').alias('monthly_demographics')
. These parameters are added as optional parameters to these methods, so everything should be backward compatible.I added some unit tests. This change is mostly refactoring existing behavior to implement protocols and adding additional optional parameters. These optional parameters just transform into the existing parameters. So, I relied on the existing tests to ensure no breaking behavior.