Skip to content

Commit

Permalink
fragrance commits
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock91 committed Jan 22, 2024
1 parent 13cf867 commit b30d242
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ snapshot-paths: ["snapshots"]
target-path: "target" # directory which will store compiled SQL files
clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_modules"
- "dbt_packages"

# on-run-start and on-run-end are SQL statement(s) or macros that run at the end of
# dbt run/dbt/seed/dbt snapshot commands.
Expand Down
26 changes: 26 additions & 0 deletions models/marts/core/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@
version: 2

models:
- name: dim_products
description: Product dimensions table
columns:
- name: product_key
data_type: number
description: unique identify of product table
tests:
- unique
- not_null

- name: brand
data_type: varchar
description: ""

- name: category_name
data_type: varchar
description: ""

- name: product_name
data_type: varchar
description: ""

- name: _fivetran_synced
data_type: timestamp_tz
description: ""

- name: dim_customers
description: Customer dimensions table
columns:
Expand Down
22 changes: 22 additions & 0 deletions models/marts/core/dim_products.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{
config(
materialized='table'
)
}}

with data as (

select
product_key,
brand,
category_name,
product_name,
_fivetran_synced
from
{{ ref("stg_products") }}
)

select
*
from
data
20 changes: 20 additions & 0 deletions models/staging/fragrance/fragrance_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2

sources:
- name: google_sheets
database: fivetran_database
tables:
- name: fragrance_products
columns:
- name: _row
data_type: number
- name: brand
data_type: varchar
- name: category
data_type: varchar
- name: product_name
data_type: varchar
- name: product_key
data_type: number
- name: _fivetran_synced
data_type: timestamp_tz
31 changes: 31 additions & 0 deletions models/staging/fragrance/stg_fragrance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: 2

models:
- name: stg_products
description: table with all fragrance and flavor related products
columns:
- name: product_key
data_type: number
description: unique identified for products
tests:
- unique
- not_null

- name: brand
data_type: varchar
description: brand of product

- name: category_name
data_type: varchar
description: category name - valid options include Beauty, Food, or Chemical
tests:
- accepted_values:
values: ['Beauty','Food','Chemical','Other']

- name: product_name
data_type: varchar
description: name of product

- name: _fivetran_synced
data_type: timestamp_tz
description: time record synced via Fivetran
31 changes: 31 additions & 0 deletions models/staging/fragrance/stg_products.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
with

source as (

select
*
from
{{ source("google_sheets", "fragrance_products") }}
),

renamed as (

select
product_key,
brand,
decode(
category,
'B', 'Beauty',
'C', 'Chemical',
'F', 'Food',
'Other'
) as category_name,
product_name,
_fivetran_synced

from source

)

select *
from renamed
4 changes: 1 addition & 3 deletions packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ packages:
- package: dbt-labs/dbt_utils
version: 0.8.5
- package: dbt-labs/codegen
version: 0.7.0
- package: elementary-data/elementary
version: 0.13.2
version: 0.12.1

0 comments on commit b30d242

Please # to comment.