Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion explore_database/inventory/inventory.sql
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ SELECT
FROM bronze.inventory_snapshots ;

--#############################################################################################
--############################## EMPLOYEE CLEAN DATA ##########################################
--############################## INVENTORY CLEAN DATA ##########################################
--#############################################################################################

SELECT
Expand Down
5 changes: 4 additions & 1 deletion explore_database/transactions/transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,7 @@ FROM
)
SELECT
*
FROM clean_transaction ;
FROM clean_transaction ;


SELECT TOP 10 * FROM bronze.sales_transactions ;
63 changes: 63 additions & 0 deletions explore_database/transactions/transction.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
--#############################################################################
-- Staging Model: src_transactions
-- Purpose: Clean and deduplicate raw bronze.sales_transactions
--#############################################################################

WITH source AS (
SELECT *
FROM {{ source('bronze', 'sales_transactions') }}
),

deduplicated AS (
SELECT *,
ROW_NUMBER() OVER (
PARTITION BY transaction_id
ORDER BY transaction_id
) AS _row_flag
FROM source
WHERE transaction_id IS NOT NULL
)

SELECT
UPPER(TRIM(transaction_id)) AS transaction_id,

CASE WHEN TRY_CAST(order_id AS INT) IS NULL OR LEN(TRIM(order_id)) < 5 THEN NULL ELSE TRY_CAST(order_id AS INT) END AS order_id,

TRY_CAST(order_line_number AS INT) AS order_line_number,

CASE
WHEN TRIM(order_date) LIKE '[A-Z][a-z][a-z][a-z]% __, ____' THEN TRY_CONVERT(DATE, order_date)
WHEN TRIM(order_date) LIKE '[A-Z][a-z][a-z] __, ____' THEN TRY_CONVERT(DATE, order_date)
WHEN TRIM(order_date) LIKE '____-__-__' THEN TRY_CONVERT(DATE, order_date)
WHEN TRIM(order_date) LIKE '____/__/__' THEN TRY_CONVERT(DATE, order_date)
WHEN TRIM(order_date) LIKE '__/__/____'
AND TRY_CONVERT(INT, SUBSTRING(TRIM(order_date), 4, 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 101)
WHEN TRIM(order_date) LIKE '__/__/____'
AND TRY_CONVERT(INT, LEFT(TRIM(order_date), 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 103)
WHEN TRIM(order_date) LIKE '__-__-____'
AND TRY_CONVERT(INT, SUBSTRING(TRIM(order_date), 4, 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 110)
WHEN TRIM(order_date) LIKE '__-__-____'
AND TRY_CONVERT(INT, LEFT(TRIM(order_date), 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 105)
ELSE TRY_CONVERT(DATE, order_date)
END AS order_date,

order_year, order_month, order_month_name, order_quarter, order_day_of_week,
TRY_CAST(customer_id AS INT) AS customer_id,
customer_full_name, customer_first_name, customer_last_name, customer_email,
customer_phone, customer_city, customer_state,
CASE WHEN TRY_CAST(customer_zip AS INT) IS NULL OR LEN(customer_zip) != 5 THEN NULL ELSE TRY_CAST(customer_zip AS INT) END AS customer_zip,
customer_region, customer_segment, customer_gender, customer_age, customer_age_group,
product_id, product_name, sku, brand, category, sub_category, department,
quantity_ordered,
unit_list_price, discount_pct, unit_selling_price,
line_total_before_tax, tax_rate_pct, tax_amount, line_total_with_tax,
store_id, store_name, store_city, store_state, store_region, store_type,
employee_id, employee_name, employee_job_title,
promo_id, promo_name,
LOWER(TRIM(sales_channel)) AS sales_channel,
payment_method, shipping_method, order_status, is_returned,
cost_price, gross_profit, data_source, record_created_ts, last_modified_ts
FROM deduplicated
WHERE _row_flag = 1;


Binary file removed venv/bin/__pycache__/daff.cpython-312.pyc
Binary file not shown.
12 changes: 6 additions & 6 deletions venv/bin/activate
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ deactivate () {
deactivate nondestructive

# on Windows, a path can contain colons and backslashes and has to be converted:
if [ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ] ; then
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
# transform D:\path\to\venv to /d/path/to/venv on MSYS
# and to /cygdrive/d/path/to/venv on Cygwin
export VIRTUAL_ENV=$(cygpath "/workspaces/dbt_learning_project/venv")
export VIRTUAL_ENV=$(cygpath /home/ritik/dbt_learning_project/venv)
else
# use the path as-is
export VIRTUAL_ENV="/workspaces/dbt_learning_project/venv"
export VIRTUAL_ENV=/home/ritik/dbt_learning_project/venv
fi

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
PATH="$VIRTUAL_ENV/"bin":$PATH"
export PATH

# unset PYTHONHOME if set
Expand All @@ -59,9 +59,9 @@ fi

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(venv) ${PS1:-}"
PS1='(venv) '"${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(venv) "
VIRTUAL_ENV_PROMPT='(venv) '
export VIRTUAL_ENV_PROMPT
fi

Expand Down
8 changes: 4 additions & 4 deletions venv/bin/activate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA
# Unset irrelevant variables.
deactivate nondestructive

setenv VIRTUAL_ENV "/workspaces/dbt_learning_project/venv"
setenv VIRTUAL_ENV /home/ritik/dbt_learning_project/venv

set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
setenv PATH "$VIRTUAL_ENV/"bin":$PATH"


set _OLD_VIRTUAL_PROMPT="$prompt"

if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
set prompt = "(venv) $prompt"
setenv VIRTUAL_ENV_PROMPT "(venv) "
set prompt = '(venv) '"$prompt"
setenv VIRTUAL_ENV_PROMPT '(venv) '
endif

alias pydoc python -m pydoc
Expand Down
8 changes: 4 additions & 4 deletions venv/bin/activate.fish
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ end
# Unset irrelevant variables.
deactivate nondestructive

set -gx VIRTUAL_ENV "/workspaces/dbt_learning_project/venv"
set -gx VIRTUAL_ENV /home/ritik/dbt_learning_project/venv

set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
set -gx PATH "$VIRTUAL_ENV/"bin $PATH

# Unset PYTHONHOME if set.
if set -q PYTHONHOME
Expand All @@ -56,7 +56,7 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
set -l old_status $status

# Output the venv prompt; color taken from the blue of the Python logo.
printf "%s%s%s" (set_color 4B8BBE) "(venv) " (set_color normal)
printf "%s%s%s" (set_color 4B8BBE) '(venv) ' (set_color normal)

# Restore the return status of the previous command.
echo "exit $old_status" | .
Expand All @@ -65,5 +65,5 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
end

set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
set -gx VIRTUAL_ENV_PROMPT "(venv) "
set -gx VIRTUAL_ENV_PROMPT '(venv) '
end
6 changes: 0 additions & 6 deletions venv/bin/daff

This file was deleted.

Loading