Skip to content

Commit

Permalink
feat!: allow configuring yaml settings inside dbt-osmosis var key
Browse files Browse the repository at this point in the history
  • Loading branch information
z3z1ma committed Jan 2, 2025
1 parent 2b501fa commit 2665652
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 172 deletions.
11 changes: 11 additions & 0 deletions demo_duckdb/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ seeds:
+dbt-osmosis: "{node.database}/{node.schema}/{node.name}.yml"

flags: {}

vars:
dbt-osmosis:
yaml_settings:
map_indent: 2
sequence_indent: 4
top_level_colon_align: false
brace_single_entry_mapping_in_flow_sequence: true
prefix_colon: " "
explicit_start: true
default_flow_style: ~
41 changes: 15 additions & 26 deletions demo_duckdb/models/jaffle_shop/main/customers.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
---
version: 2
models:
- name: customers
description: This table has basic information about a customer, as well as some derived facts based on a customer's orders
- name : customers
description : This table has basic information about a customer, as well as some derived facts based on a customer's orders

columns:
- name: customer_id
description: This is a unique identifier for a customer
tests:
columns :
- name : customer_id
description : This is a unique identifier for a customer
tests :
- unique
- not_null

data_type: INTEGER
- name: first_name
description: Customer's first name. PII.
data_type: VARCHAR
- name: last_name
description: Customer's last name. PII.
data_type: VARCHAR
- name: first_order
description: Date (UTC) of a customer's first order
data_type: DATE
- name: most_recent_order
description: Date (UTC) of a customer's most recent order
data_type: DATE
- name: number_of_orders
description: Count of the number of orders a customer has placed
data_type: BIGINT
- name: customer_lifetime_value
data_type: DOUBLE
- name: customer_average_value
data_type: DECIMAL(18,3)
data_type : INTEGER
- {name : first_name, description : Customer's first name. PII., data_type : VARCHAR}
- {name : last_name, description : Customer's last name. PII., data_type : VARCHAR}
- {name : first_order, description : Date (UTC) of a customer's first order, data_type : DATE}
- {name : most_recent_order, description : Date (UTC) of a customer's most recent order, data_type : DATE}
- {name : number_of_orders, description : Count of the number of orders a customer has placed, data_type : BIGINT}
- {name : customer_lifetime_value, data_type : DOUBLE}
- {name : customer_average_value, data_type : 'DECIMAL(18,3)'}
85 changes: 42 additions & 43 deletions demo_duckdb/models/jaffle_shop/main/orders.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,58 @@
---
version: 2
models:
- name: orders
description: This table has basic information about orders, as well as some derived facts based on payments
- name : orders
description : This table has basic information about orders, as well as some derived facts based on payments

columns:
- name: order_id
tests:
columns :
- name : order_id
tests :
- unique
- not_null
description: This is a unique identifier for an order
data_type: INTEGER
- name: customer_id
description: Foreign key to the customers table
tests:
description : This is a unique identifier for an order
data_type : INTEGER
- name : customer_id
description : Foreign key to the customers table
tests :
- not_null
- relationships:
to: ref('customers')
field: customer_id
- relationships :
to : ref('customers')
field : customer_id

data_type: INTEGER
- name: order_date
description: Date (UTC) that the order was placed
data_type: DATE
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']
data_type : INTEGER
- {name : order_date, description : Date (UTC) that the order was placed, data_type : DATE}
- name : status
tests :
- accepted_values :
values : ['placed', 'shipped', 'completed', 'return_pending', 'returned']

description: '{{ doc("orders_status") }}'
data_type: VARCHAR
- name: credit_card_amount
description: Amount of the order (AUD) paid for by credit card
tests:
description : '{{ doc("orders_status") }}'
data_type : VARCHAR
- name : credit_card_amount
description : Amount of the order (AUD) paid for by credit card
tests :
- not_null

data_type: DOUBLE
- name: coupon_amount
description: Amount of the order (AUD) paid for by coupon
tests:
data_type : DOUBLE
- name : coupon_amount
description : Amount of the order (AUD) paid for by coupon
tests :
- not_null

data_type: DOUBLE
- name: bank_transfer_amount
description: Amount of the order (AUD) paid for by bank transfer
tests:
data_type : DOUBLE
- name : bank_transfer_amount
description : Amount of the order (AUD) paid for by bank transfer
tests :
- not_null

data_type: DOUBLE
- name: gift_card_amount
description: Amount of the order (AUD) paid for by gift card
tests:
data_type : DOUBLE
- name : gift_card_amount
description : Amount of the order (AUD) paid for by gift card
tests :
- not_null
data_type: DOUBLE
- name: amount
description: Total amount (AUD) of the order
tests:
data_type : DOUBLE
- name : amount
description : Total amount (AUD) of the order
tests :
- not_null
data_type: DOUBLE
data_type : DOUBLE
35 changes: 14 additions & 21 deletions demo_duckdb/models/jaffle_shop/main/orders_prefix.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
---
version: 2
models:
- name: orders_prefix
columns:
- name: o_order_id
data_type: INTEGER
- name: o_customer_id
data_type: INTEGER
- name: o_order_date
data_type: DATE
- name: o_status
description: '{{ doc("orders_status") }}'
data_type: VARCHAR
- name: o_credit_card_amount
data_type: DOUBLE
- name: o_coupon_amount
data_type: DOUBLE
- name: o_bank_transfer_amount
data_type: DOUBLE
- name: o_gift_card_amount
data_type: DOUBLE
- name: o_amount
data_type: DOUBLE
- name : orders_prefix
columns :
- {name : o_order_id, data_type : INTEGER}
- {name : o_customer_id, data_type : INTEGER}
- {name : o_order_date, data_type : DATE}
- name : o_status
description : '{{ doc("orders_status") }}'
data_type : VARCHAR
- {name : o_credit_card_amount, data_type : DOUBLE}
- {name : o_coupon_amount, data_type : DOUBLE}
- {name : o_bank_transfer_amount, data_type : DOUBLE}
- {name : o_gift_card_amount, data_type : DOUBLE}
- {name : o_amount, data_type : DOUBLE}
17 changes: 8 additions & 9 deletions demo_duckdb/models/staging/jaffle_shop/main/stg_customers.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
version: 2
models:
- name: stg_customers
columns:
- name: customer_id
tests:
- name : stg_customers
columns :
- name : customer_id
tests :
- unique
- not_null

data_type: INTEGER
- name: first_name
data_type: VARCHAR
- name: last_name
data_type: VARCHAR
data_type : INTEGER
- {name : first_name, data_type : VARCHAR}
- {name : last_name, data_type : VARCHAR}
29 changes: 14 additions & 15 deletions demo_duckdb/models/staging/jaffle_shop/main/stg_orders.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
version: 2
models:
- name: stg_orders
columns:
- name: order_id
tests:
- name : stg_orders
columns :
- name : order_id
tests :
- unique
- not_null
data_type: INTEGER
- name: customer_id
data_type: INTEGER
- name: order_date
data_type: DATE
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']
data_type : INTEGER
- {name : customer_id, data_type : INTEGER}
- {name : order_date, data_type : DATE}
- name : status
tests :
- accepted_values :
values : ['placed', 'shipped', 'completed', 'return_pending', 'returned']

data_type: VARCHAR
description: '{{ doc("orders_status") }}'
data_type : VARCHAR
description : '{{ doc("orders_status") }}'
27 changes: 13 additions & 14 deletions demo_duckdb/models/staging/jaffle_shop/main/stg_payments.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
---
version: 2
models:
- name: stg_payments
columns:
- name: payment_id
tests:
- name : stg_payments
columns :
- name : payment_id
tests :
- unique
- not_null
data_type: integer
- name: order_id
data_type: integer
- name: payment_method
tests:
- accepted_values:
values: ["credit_card", "coupon", "bank_transfer", "gift_card"]
data_type: varchar
- name: amount
data_type: double
data_type : integer
- {name : order_id, data_type : integer}
- name : payment_method
tests :
- accepted_values :
values : ["credit_card", "coupon", "bank_transfer", "gift_card"]
data_type : varchar
- {name : amount, data_type : double}
18 changes: 8 additions & 10 deletions demo_duckdb/seeds/jaffle_shop/main/raw_customers.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
version: 2
seeds:
- name: raw_customers
meta:
foo: bar
columns:
- name: id
data_type: INTEGER
- name: first_name
data_type: VARCHAR
- name: last_name
data_type: VARCHAR
- name : raw_customers
meta :
foo : bar
columns :
- {name : id, data_type : INTEGER}
- {name : first_name, data_type : VARCHAR}
- {name : last_name, data_type : VARCHAR}
20 changes: 9 additions & 11 deletions demo_duckdb/seeds/jaffle_shop/main/raw_orders.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
version: 2
seeds:
- name: raw_orders
columns:
- name: id
data_type: INTEGER
- name: user_id
data_type: INTEGER
- name: order_date
data_type: DATE
- name: status
description: '{{ doc("orders_status") }}'
data_type: VARCHAR
- name : raw_orders
columns :
- {name : id, data_type : INTEGER}
- {name : user_id, data_type : INTEGER}
- {name : order_date, data_type : DATE}
- name : status
description : '{{ doc("orders_status") }}'
data_type : VARCHAR
17 changes: 7 additions & 10 deletions demo_duckdb/seeds/jaffle_shop/main/raw_payments.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
---
version: 2
seeds:
- name: raw_payments
columns:
- name: id
data_type: INTEGER
- name: order_id
data_type: INTEGER
- name: payment_method
data_type: VARCHAR
- name: amount
data_type: INTEGER
- name : raw_payments
columns :
- {name : id, data_type : INTEGER}
- {name : order_id, data_type : INTEGER}
- {name : payment_method, data_type : VARCHAR}
- {name : amount, data_type : INTEGER}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "dbt-osmosis"
version = "1.1.0"
version = "1.1.1"
description = "A dbt utility for managing YAML to make developing with dbt more delightful."
readme = "README.md"
license = { text = "Apache-2.0" }
Expand Down
Loading

0 comments on commit 2665652

Please sign in to comment.