From 7d70b2c5f8b3686fe0ea8a76304dad7fa1cffb85 Mon Sep 17 00:00:00 2001 From: Jo Lares Date: Mon, 26 Feb 2024 19:38:54 -0500 Subject: [PATCH] chore: Add example dbt exposures --- dbt_profiles.snowflake.yml | 12 ++++---- docs/git-branching-model.drawio.svg | 6 ++-- models/example/schema.yml | 43 +++++++++++++++++++++++++++++ package-lock.yml | 6 ++++ packages.yml | 8 ++++++ setup.sh | 19 +++++-------- 6 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 package-lock.yml create mode 100644 packages.yml diff --git a/dbt_profiles.snowflake.yml b/dbt_profiles.snowflake.yml index 0415ea9..26efcc2 100644 --- a/dbt_profiles.snowflake.yml +++ b/dbt_profiles.snowflake.yml @@ -8,13 +8,13 @@ dbt_demo: outputs: dev: - account: __SNOWFLAKE_ACCOUNT__ - database: __SNOWFLAKE_DATABASE__ - password: __SNOWFLAKE_PASSWORD__ - role: __SNOWFLAKE_ROLE__ + account: "{{ env_var('SNOWFLAKE_ACCOUNT') }}" + database: "{{ env_var('SNOWFLAKE_DATABASE') }}" + password: "{{ env_var('SNOWFLAKE_PASSWORD') }}" + role: "{{ env_var('SNOWFLAKE_ROLE') }}" schema: PUBLIC threads: 10 type: snowflake - user: __SNOWFLAKE_USER__ - warehouse: __SNOWFLAKE_WAREHOUSE__ + user: "{{ env_var('SNOWFLAKE_USER') }}" + warehouse: "{{ env_var('SNOWFLAKE_WAREHOUSE') }}" target: dev diff --git a/docs/git-branching-model.drawio.svg b/docs/git-branching-model.drawio.svg index 30754eb..06fd3cf 100644 --- a/docs/git-branching-model.drawio.svg +++ b/docs/git-branching-model.drawio.svg @@ -1,6 +1,4 @@ - + - - - + \ No newline at end of file diff --git a/models/example/schema.yml b/models/example/schema.yml index 1a49561..fddc3f9 100644 --- a/models/example/schema.yml +++ b/models/example/schema.yml @@ -1,5 +1,18 @@ --- version: 2 + +## +## DAG Sources +## See dbt docs: https://docs.getdbt.com/docs/build/sources +## +sources: + - name: jaffle_shop + database: raw + schema: jaffle_shop + tables: + - name: orders + - name: customers + models: - name: my_first_dbt_model description: A starter dbt model @@ -13,3 +26,33 @@ models: - name: id description: The primary key for this table tests: [unique, not_null] + +## +## Exposures define downstream uses of the dbt project, +## See dbt docs: https://docs.getdbt.com/docs/build/exposures +## +exposures: + - name: weekly_jaffle_metrics + label: Weekly Jaffle Metrics + type: dashboard + + # Indicates the level of confidence (stability) in the exposure. + # Options: + # - high (i.e. for a well-established dashboard, widely used and trusted within your organizatio) + # - medium + # - low (i.e. for a new or experimental analysis) + maturity: high + + url: https://bi.tool/dashboards/1 + + description: > + Did someone say "exponential growth"? + + depends_on: + - ref('my_first_dbt_model') + - source('jaffle_shop', 'orders') + # - metric('count_orders') + + owner: + name: Jo Lares + email: jolares@jaffleshop.com \ No newline at end of file diff --git a/package-lock.yml b/package-lock.yml new file mode 100644 index 0000000..8f0e8f7 --- /dev/null +++ b/package-lock.yml @@ -0,0 +1,6 @@ +packages: +- package: dbt-labs/codegen + version: 0.12.1 +- package: dbt-labs/dbt_utils + version: 1.1.1 +sha1_hash: acdde602cd2e228b1dac1cf1a7e5f98f12c16b3b diff --git a/packages.yml b/packages.yml new file mode 100644 index 0000000..c610ca4 --- /dev/null +++ b/packages.yml @@ -0,0 +1,8 @@ +packages: + # See https://hub.getdbt.com/dbt-labs/codegen/latest/ + - package: dbt-labs/codegen + version: 0.12.1 + + # See https://github.com/tnightengale/dbt-meta-testing/tree/0.3.6/ + - package: tnightengale/dbt_meta_testing + version: 0.3.6 \ No newline at end of file diff --git a/setup.sh b/setup.sh index 6af8218..fba7ca4 100644 --- a/setup.sh +++ b/setup.sh @@ -4,12 +4,12 @@ ## if [ -z "${DBT_PROJECT_NAME}" ]; then - echo "Environment variable DBT_PROJECT_NAME is not set" + echo "[Error] Environment variable DBT_PROJECT_NAME is not set" exit 1 fi if [ -z "${DBT_WAREHOUSE_PROVIDER}" ]; then - echo "Environment variable DBT_WAREHOUSE_PROVIDER is not set" + echo "[Error] Environment vartarget='dev'iable DBT_WAREHOUSE_PROVIDER is not set" exit 1 fi @@ -72,16 +72,11 @@ fi # Confirm that the dbt installation was successful. dbt --version -python -m pip install -r requirements.txt - -# dbt init $DBT_PROJECT_NAME - -## -## Setup dbt connection profile to data warehouse -## +# Install dbt packages specified in package.yml +dbt deps -# TODO -# ... +# Install Python packages +python -m pip install -r requirements.txt # Verify dbt connection profile to data warehouse -dbt debug \ No newline at end of file +dbt debug