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

[Feature] Use Templates for Defining Metric Filters #505

Closed
3 tasks done
plypaul opened this issue May 8, 2023 · 2 comments
Closed
3 tasks done

[Feature] Use Templates for Defining Metric Filters #505

plypaul opened this issue May 8, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request triage Tasks that need to be triaged

Comments

@plypaul
Copy link
Contributor

plypaul commented May 8, 2023

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing metricflow functionality, rather than a Big Idea better suited to a discussion

Describe the feature

When defining a metric, it's possible to specify a filter for the measure. For example, to define the canada_bookings metric, you could use the bookings measure with the filter that uses the country dimension. Previously, in specifying the filter, the user would specify the filter as raw SQL like listing__country == 'ca'. The dunder syntax was used to specify the entity path / join path so that the right dimension was used (e.g. not guest__country). There were a couple of issues with this approach.

  • We're moving away from the dunder syntax as it's difficult to specify additional qualities about the entity path.
  • To extract the dimensions that are used, the filter needed to be parsed via a SQL parser, which could be error prone with the variety of SQL dialects and new features.

Instead, the proposal is to support templating in the filter string, so that future path specifications will be easier to support. e.g. {{ dimension('listing', entity_path=['listing'] }} == 'ca'. In addition, the use of a template will eliminate the need for SQL parsing.

Describe alternatives you've considered

See previous implementation in the description.

Who will this benefit?

With the templated syntax, there will be fewer issues supporting new SQL engines and enable us to later add improved join path specification.

Are you interested in contributing this feature?

Yes

Anything else?

No response

@plypaul plypaul added enhancement New feature or request triage Tasks that need to be triaged labels May 8, 2023
@plypaul plypaul self-assigned this May 8, 2023
plypaul added a commit that referenced this issue May 8, 2023
plypaul added a commit that referenced this issue May 8, 2023
plypaul added a commit that referenced this issue May 8, 2023
plypaul added a commit that referenced this issue May 11, 2023
plypaul added a commit that referenced this issue May 11, 2023
@callum-mcdata
Copy link
Contributor

@plypaul similar to other issue, is this one good to be closed out?

@Jstein77
Copy link
Contributor

Looks like the #506 resolves this issue so closing it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Tasks that need to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants