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

Metrics package #1

Merged
merged 72 commits into from
Feb 9, 2022
Merged

Metrics package #1

merged 72 commits into from
Feb 9, 2022

Conversation

joellabes
Copy link
Contributor

GitHub doesn't make it easy to do code review on a whole repository, so I'm tricking it by following these steps.

The big questions:

  • Does this do what it's meant to?
  • Does it do it in a good way?
  • Are there other things it needs to urgently do before being given to third parties to start using?
  • Assorted questions raised in TODO comments throughout the repo.

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

Very cool stuff! I started pulling this apart just to understand how the pieces fit together, and in service of standing up some initial CI (#2). I didn't get to the breadth of review I'd hoped, hoping to get some more time later to keep going

macros/aggregate_primary_metric.sql Outdated Show resolved Hide resolved
macros/get_metric_sql.sql Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

@joellabes - this is a masterpiece!! A masterpiece!!

I need to spend more time with this, and will ideally pull the branch down and take it for a spin locally. I left some high-level questions in here to start, but am definitely planning on taking another, deeper pass too :)

Really incredible work so far 💪 💪 💪

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated
```

### Time Grains
The package protects against nonsensical secondary calculations, such as a month-to-date aggregate of data which has been rolled up to the quarter. If you customise your calendar (for example by adding a [4-5-4 retail calendar](https://nrf.com/resources/4-5-4-calendar) month), you will need to override the `get_grain_order()` macro. In that case, you might remove `month` and replace it with `month_4_5_4`. All date columns must be prefixed with `date_` in the table, but this is not necessary in the model config.
Copy link
Contributor

Choose a reason for hiding this comment

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

just putting a placeholder to come back to this once i've scanned further down this PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@drewbanin if you had anything else to say on the topic, now's the time 🕐

README.md Outdated Show resolved Hide resolved

{% macro get_metric_calendar(ref_name) %}
--TODO: this is HORRID.
{% do return(metrics.get_metric_relation([(ref_name.split("'")[1])])) %}
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this macro do? I'm having a hard time following the logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm assuming you mean just the get_metric_calendar one - if you mean this whole file, refer to this thread

Basically, even though the metric yml file has its model as a full ref

    - name: slack_joiners
      model: ref('dim_slack_users_2')

the refs array from the graph contains just the string, inside a second array:

{
   "fqn":["joel_sandbox","metrics","slack_joiners"],
   "unique_id":"metric.joel_sandbox.slack_joiners",
   "time_grains":["day", "week", "month"],
   "dimensions":["has_messaged"],
   "resource_type":"metric",
   "refs":[
      [
         "dim_slack_users_2"
      ]
   ],
   "created_at":1642578505.5324879
}

Whereas the calendar variable:

vars:
  dbt_metrics_calendar_model: ref('all_days_extended_2')

comes through as the entire ref string (it hasn't been parsed or processed yet). This splits on the ' character, takes the second element, and wraps it inside an array, to have the same shape as get_metric_relation expects, which is a perfect fit for the metric's model style.

I'm 100% sure there's a better way to do it, but my graph-fu was failing me so I figured we'd just talk about it here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jtcohen6 do you have any tricks up your sleeve that can make this less janky?

macros/get_metric_sql.sql Show resolved Hide resolved
macros/get_metric_sql.sql Show resolved Hide resolved
macros/get_metric_sql.sql Outdated Show resolved Hide resolved
Kyle Wigley and others added 6 commits January 24, 2022 17:58
* first pass at setting up postgres integration tests

* try number 2

* try number 3

* try number 4

* try number 5

* try number 6

* try number 7

* add snowflake integration tests

* use snowflake target

* add rest of 'em

* try again please

* fix target arg

* fix syntax

* use json for bigquery keyfile

* fix env var

* rename workflow

* fix bigquery

* more fix bigquery

* more fix bigquery

* re run

* test

* asdf

* aha!
@cla-bot cla-bot bot added the cla:yes The CLA has been signed label Feb 9, 2022
@joellabes joellabes merged commit 0b03e6b into empty Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes The CLA has been signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants