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

Support for descending & date_part in query interface #154

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

DevonFulcher
Copy link
Contributor

This PR adds support for date_part and descending in the query interface. I decided to raise an error for date_part for now. We will have to revisit that.

Checklist

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.

Makes sense to me! We'll see if adjusting protocols makes sense as we get more of these implemented. For now being able to throw the errors from the relevant class, instead of some central handler, seems like a much bigger advantage than potential type safety, especially given how we expect these to be used.

Comment on lines +36 to +43
def descending(self, _is_descending: bool) -> QueryInterfaceDimension:
"""Set the sort order for order-by."""
raise InvalidQuerySyntax("descending is invalid in the where parameter and filter spec")

def date_part(self, _date_part: str) -> QueryInterfaceDimension:
"""Date part to extract from the dimension."""
raise InvalidQuerySyntax("date_part isn't currently supported in the where parameter and filter spec")

Copy link
Collaborator

Choose a reason for hiding this comment

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

I saw this in the other implementations as well and I wonder if there's a way for us to structure the protocols so that things are just typed, but I don't know if that's worth the complexity.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Related question: in practice, will anybody other than us (or another implementer of a MetricFlow query interface) ever initialize one of these things directly? I don't think the WhereFilterDimension is a thing any end user will ever interact with except via our parser, is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

structure the protocols so that things are just typed

I believe this is typed correctly. Users of the JDBC interface don't get the benefits of an LSP, so they are reliant on error messages to help them write correct code.

will anybody other than us (or another implementer of a MetricFlow query interface) ever initialize one of these things directly?

Right, I think this is just an internal class.

Comment on lines +64 to +65
descending: Optional[bool] = None,
date_part_name: Optional[str] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these also be added to the QueryInterfaceDimensionFactory.create() method?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops, I somehow forgot about this between writing it and submitting the review. If this was an oversight please fix before merge!

Copy link
Contributor Author

@DevonFulcher DevonFulcher Sep 25, 2023

Choose a reason for hiding this comment

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

Hmm...good thought. To be honest, I'm not sure what the best design approach is. time_granularity_name is already a parameter for QueryInterfaceTimeDimensionFactory, but not QueryInterfaceDimensionFactory. I had assumed we would continue that pattern. But, if we go with that approach, maybe it would be better to remove entity_path from QueryInterfaceDimensionFactory and place it on QueryInterfaceDimension instead too.

@DevonFulcher DevonFulcher merged commit b798ea5 into main Sep 25, 2023
@DevonFulcher DevonFulcher deleted the query_interface_updates branch September 25, 2023 18:36
DevonFulcher added a commit that referenced this pull request Oct 3, 2023
Due to MetricFlow's reliance on version 0.2.x of DSI, the updates to support Dimension(...).grain(...) need to be made to this branch as well. I just combined the work from these PRs into this one #156, #154, #152
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.

2 participants