Skip to content

Commit 7583e7f

Browse files
izeigermancrericha
andauthored
Add sushi dbt project (#4)
Co-authored-by: Chris Rericha <67359577+crericha@users.noreply.github.com>
1 parent 8acb3de commit 7583e7f

18 files changed

Lines changed: 231 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
target/
3+
dbt_packages/
4+
logs/

tests/projects/sushi_dbt/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Welcome to your new dbt project!
2+
3+
### Using the starter project
4+
5+
Try running the following commands:
6+
- dbt run
7+
- dbt test
8+
9+
10+
### Resources:
11+
- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction)
12+
- Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers
13+
- Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support
14+
- Find [dbt events](https://events.getdbt.com) near you
15+
- Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices

tests/projects/sushi_dbt/analyses/.gitkeep

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
name: 'sushi'
3+
version: '1.0.0'
4+
config-version: 2
5+
profile: 'sushi'
6+
7+
model-paths: ["models"]
8+
analysis-paths: ["analyses"]
9+
test-paths: ["tests"]
10+
seed-paths: ["seeds"]
11+
macro-paths: ["macros"]
12+
snapshot-paths: ["snapshots"]
13+
14+
target-path: "target" # directory which will store compiled SQL files
15+
clean-targets: # directories to be removed by `dbt clean`
16+
- "target"
17+
- "dbt_packages"
18+
19+
# Configuring models
20+
# Full documentation: https://docs.getdbt.com/docs/configuring-models
21+
22+
models:
23+
sushi:
24+
cleansed:
25+
+schema: cleansed
26+
+materialized: table
27+
db:
28+
+schema: db
29+
+materialized: table

tests/projects/sushi_dbt/macros/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT DISTINCT
2+
customer_id::INT AS customer_id
3+
FROM {{ source('raw', 'orders') }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{
2+
config(
3+
materialized='incremental',
4+
incremental_strategy='delete+insert',
5+
cluster_by=['ds'],
6+
unique_key=['ds'],
7+
)
8+
}}
9+
10+
SELECT
11+
id::DOUBLE AS id, /* Primary key */
12+
name::TEXT AS name, /* Name of the sushi */
13+
price::DOUBLE AS price, /* Price of the sushi */
14+
ds::TEXT AS ds /* Date */
15+
FROM {{ source('raw', 'items') }}
16+
{% if is_incremental() %}
17+
WHERE
18+
ds > (select max(ds) from {{ this }})
19+
{% endif %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{
2+
config(
3+
materialized='incremental',
4+
incremental_strategy='delete+insert',
5+
cluster_by=['ds'],
6+
unique_key=['ds']
7+
)
8+
}}
9+
10+
SELECT
11+
id::INT AS id, /* Primary key */
12+
order_id::INT AS order_id, /* Order id */
13+
item_id::INT AS item_id, /* Item id */
14+
quantity::INT AS quantity, /* Quantity of items ordered */
15+
ds::TEXT AS ds /* Date of order */
16+
FROM {{ source('raw', 'order_items') }}
17+
{% if is_incremental() %}
18+
WHERE
19+
ds > (select max(ds) from {{ this }})
20+
{% endif %}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{
2+
config(
3+
materialized='incremental',
4+
incremental_strategy='delete+insert',
5+
cluster_by=['ds'],
6+
unique_key=['ds']
7+
)
8+
}}
9+
10+
SELECT
11+
id::INT AS id, /* Primary key */
12+
customer_id::INT AS customer_id, /* Id of customer who made the order */
13+
waiter_id::INT AS waiter_id, /* Id of waiter who took the order */
14+
start_ts::TEXT AS start_ts, /* Start timestamp */
15+
end_ts::TEXT AS end_ts, /* End timestamp */
16+
ds::TEXT AS ds /* Date of order */
17+
FROM {{ source('raw', 'orders') }}
18+
{% if is_incremental() %}
19+
WHERE
20+
ds > (select max(ds) from {{ this }})
21+
{% endif %}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
3+
models:
4+
- name: items
5+
- name: orders
6+
- name: order_items
7+
- name: customers
8+
- name: waiters
9+
sources:
10+
- name: raw
11+
tables:
12+
- name: items
13+
- name: orders
14+
- name: order_items

0 commit comments

Comments
 (0)