-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from EvavW/models-module
finish fundamentals
- Loading branch information
Showing
11 changed files
with
96 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% docs order_status %} | ||
|
||
One of the following values: | ||
|
||
| status | definition | | ||
|----------------|--------------------------------------------------| | ||
| placed | Order placed, not yet shipped | | ||
| shipped | Order has been shipped, not yet been delivered | | ||
| completed | Order has been received by customers | | ||
| return pending | Customer indicated they want to return this item | | ||
| returned | Item has been returned | | ||
|
||
{% enddocs %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: jaffle_shop | ||
database: dbt-tutorial | ||
|
||
schema: jaffle_shop | ||
tables: | ||
- name: customers | ||
loaded_at_field: _batched_at | ||
freshness: | ||
warn_after: {count: 12, period: hour} | ||
error_after: {count: 24, period: hour} | ||
- name: orders | ||
loaded_at_field: _batched_at | ||
freshness: | ||
warn_after: {count: 12, period: hour} | ||
error_after: {count: 24, period: hour} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
select | ||
select | ||
id as customer_id, | ||
first_name, | ||
last_name | ||
|
||
from dbt-tutorial.jaffle_shop.customers | ||
from {{ source('jaffle_shop', 'customers') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: stg_customers | ||
description: Staged customer data from our jaffle shop app. | ||
columns: | ||
- name: customer_id | ||
description: The primary key for customers. | ||
tests: | ||
- unique | ||
- not_null | ||
|
||
- name: stg_orders | ||
description: Staged order data from our jaffle shop app. | ||
columns: | ||
- name: order_id | ||
description: Primary key for orders. | ||
tests: | ||
- unique | ||
- not_null | ||
- name: status | ||
description: "{{ doc('order_status') }}" | ||
tests: | ||
- accepted_values: | ||
values: | ||
- completed | ||
- shipped | ||
- returned | ||
- placed | ||
- return_pending | ||
- name: customer_id | ||
description: Foreign key to stg_customers.customer_id. | ||
tests: | ||
- relationships: | ||
to: ref('stg_customers') | ||
field: customer_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
select | ||
id as payment_id, | ||
orderid as order_id, | ||
paymentmethod, | ||
paymentmethod as payment_method, | ||
status, | ||
amount, | ||
created, | ||
_batched_at | ||
-- amount is stored in cents, convert it to dollars | ||
amount / 100 as amount, | ||
created as created_at | ||
from {{ source('stripe', 'payment') }} | ||
|
||
from dbt-tutorial.stripe.payment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: stripe | ||
database: dbt-tutorial | ||
schema: stripe | ||
tables: | ||
- name: payment | ||
loaded_at_field: _batched_at | ||
freshness: | ||
warn_after: {count: 12, period: hour} | ||
error_after: {count: 24, period: hour} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Refunds have a negative amount, so the total amount should always be >= 0. | ||
-- Therefore return records where this isn't true to make the test fail. | ||
select | ||
order_id, | ||
sum(amount) as total_amount | ||
from {{ ref('stg_payments') }} | ||
group by 1 | ||
having not(total_amount >= 0) |