Skip to content

Commit

Permalink
Making some staging models views so it's faster
Browse files Browse the repository at this point in the history
  • Loading branch information
JonCrawford committed Apr 6, 2024
1 parent 0a9d3d3 commit f63a75a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 35 deletions.
28 changes: 12 additions & 16 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_packages"

data_tests:
+store_failures: true

on-run-start:
- "{{ url_decode_udf() }}"

Expand Down Expand Up @@ -135,11 +132,10 @@ models:

generic:
+schema: support
staging:
stg_shop_infos:
# +materialized: incremental
# +on_schema_change: "sync_all_columns"
# +unique_key: shop_subdomain
#staging:
# stg_shop_infos:
# +on_schema_change: "sync_all_columns"
# +unique_key: shop_subdomain
mesa:
marts:
step_runs:
Expand Down Expand Up @@ -179,17 +175,17 @@ models:
# +materialized: "{{ 'view' if target.name in ['prod', 'default'] else 'table' }}"
+schema: support
stg_step_runs:
+materialized: incremental
+on_schema_change: "sync_all_columns"
+unique_key: step_run_id
+cluster_by: ["workflow_run_id"]
+materialized: view
# +on_schema_change: "sync_all_columns"
# +unique_key: step_run_id
# +cluster_by: ["workflow_run_id"]
stg_workflows:
+unique_key: workflow_id
stg_workflow_runs:
+materialized: incremental
+on_schema_change: "sync_all_columns"
+unique_key: workflow_run_id
+cluster_by: ["shop_subdomain"]
+materialized: view
# +on_schema_change: "sync_all_columns"
# +unique_key: workflow_run_id
# +cluster_by: ["shop_subdomain"]
stg_shops:
+cluster_by: ["date_trunc('day', first_installed_at_pt)"]
+unique_key: shop_subdomain
Expand Down
2 changes: 1 addition & 1 deletion macros/generic_tests/check_boolean_values.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- tests/check_boolean_values.sql
-- generic_tests/check_boolean_values.sql
{# Checks that a column has both True and False values. #}
{% macro test_check_boolean_values(model, column_name) %}
with validation as (
Expand Down
2 changes: 1 addition & 1 deletion models/mesa/marts/_step_runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ models:

data_tests:
- dbt_expectations.expect_table_row_count_to_be_between:
min_value: 10000
min_value: 1000000
columns:
- name: step_run_id
description: The unique identifier for the step run.
Expand Down
2 changes: 1 addition & 1 deletion models/mesa/marts/_workflow_runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ models:
description: individual mesa workflow executions.
data_tests:
- dbt_expectations.expect_table_row_count_to_be_between:
min_value: 10000
min_value: 100000
- dbt_expectations.expect_table_row_count_to_be_between:
min_value: 1000
row_condition: is_billable
Expand Down
13 changes: 2 additions & 11 deletions models/mesa/staging/_stg_step_runs.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
version: 2
models:
- name: stg_step_runs
data_tests:
- dbt_expectations.expect_table_row_count_to_be_between:
min_value: 1000000
columns:
- name: step_run_id
data_tests:
- not_null
- unique
description: The unique identifier for the step run.
- name: workflow_run_id
data_tests:
Expand All @@ -21,11 +17,6 @@ models:
metabase.fk_target_field: workflow_id
data_tests:
- not_null
- relationships_proportion:
to: ref('stg_workflows')
field: workflow_id
warn_if: ">1"
error_if: ">5"
description: The foreign key to the originating workflow
- name: step_run_at_utc
data_tests:
Expand Down Expand Up @@ -67,8 +58,8 @@ models:
- not_null
description: The type of step that was run. `input` or `output`.
- name: RUN_STATUS
data_tests:
- not_null
# data_tests:
# - not_null
- name: TRIES
- name: UPDATED_AT
- name: SHOP_SUBDOMAIN
Expand Down
7 changes: 2 additions & 5 deletions models/mesa/staging/_stg_workflow_runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ models:
description:
a intermediate model that isolates the very first step executed of
each workflow run.
data_tests:
- dbt_expectations.expect_table_row_count_to_be_between:
min_value: 100000
columns:
- name: workflow_run_id
data_tests:
Expand All @@ -16,8 +13,8 @@ models:
description:
a step/workflow is only billed once -- not for each step. so only
true for the first trigger.
data_tests:
- not_null
# data_tests:
# - not_null
- name: shop_subdomain
data_tests:
- not_null
Expand Down

0 comments on commit f63a75a

Please sign in to comment.