Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make some of those sweet sweet changes #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion models/marts/_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ models:
description: unique identifier for a store
tests:
- unique
- not_null


- name: call_centers
Expand Down
19 changes: 2 additions & 17 deletions models/marts/stores.sql
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
with
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a select statement to explicitly define the columns you want to include from each referenced model. This improves readability and makes it easier to track changes in the future. For example:

select 
    stores.store_sk,
    stores.store_id,
    stores.store_name,
    -- Add other relevant columns from stores
    date_dim.date as store_closed_date

from {{ ref('stg_tpcds_core__store') }} as stores
left join {{ ref('stg_tpcds_core__date_dim') }} as date_dim
    on stores.closed_date_sk = date_dim.date_sk

This approach also allows you to rename columns if needed and ensures that only necessary columns are included in the final output.

More info

Source: dbt Labs - SQL Style Guide


stores as (
select * from {{ ref('stg_tpcds_core__store') }}
),

date_dim as (

select * from {{ ref('stg_tpcds_core__date_dim') }}

),

final as (

select
stores.*,
date_dim.date as store_closed_date

from stores
left join date_dim
from {{ ref('stg_tpcds_core__store') }} as stores
left join {{ ref('stg_tpcds_core__date_dim') }} as date_dim
on stores.closed_date_sk = date_dim.date_sk

)

select * from final
2 changes: 1 addition & 1 deletion models/marts/transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final as (
customers.is_preferred_customer,
customers.gender,
stores.store_name,
stores.city,
stores.alksfj_city,
stores.state

from unioned
Expand Down
2 changes: 1 addition & 1 deletion models/staging/tpcds_core/stg_tpcds_core__store.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ renamed as (
s_street_name as street_name,
s_street_type as street_type,
s_suite_number as suite_number,
s_city as city,
s_city as alksfj_city,
s_county as county,
s_state as state,
s_zip as zip,
Expand Down