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

fix: derived metrics in dbt Cloud #198

Merged
merged 2 commits into from
Mar 31, 2023
Merged

Conversation

betodealmeida
Copy link
Member

There are two ways to represent derived metrics in dbt. Before dbt 1.3:

- name: some_ratio
  type: expression
  sql: "{{metric(a)}} / {{metric(b)}}"

Starting with dbt 1.3:

- name: some_ratio
  calculation_method: derived
  expression: "{{metric(a)}} / {{metric(b)}}

For some reason, the API for dbt Cloud returns a derived metric as:

{
    "name": "ratio_of_paying_customers",
    "sql": "paying_customers / total_customers",
    "type": "derived",
    "unique_id": "metric.jaffle_shop.ratio_of_paying_customers",
}

This PR fixes the is_derived function to handle this correctly.

@betodealmeida betodealmeida force-pushed the fix_multiple_model_metrics branch 2 times, most recently from 39c1118 to 8d8bceb Compare March 31, 2023 03:08
Copy link

@lilykuang lilykuang left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants