Skip to content

Commit ab72955

Browse files
Merge pull request #78 from Ritik574-coder/dbt_branch
adding file stracture and sql fine info , and relationship
2 parents b8f962e + 6cf2d27 commit ab72955

7,242 files changed

Lines changed: 93 additions & 716460 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

explore_database/inventory/inventory.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ SELECT
593593
FROM bronze.inventory_snapshots ;
594594

595595
--#############################################################################################
596-
--############################## EMPLOYEE CLEAN DATA ##########################################
596+
--############################## INVENTORY CLEAN DATA ##########################################
597597
--#############################################################################################
598598

599599
SELECT

explore_database/transactions/transactions.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,7 @@ FROM
281281
)
282282
SELECT
283283
*
284-
FROM clean_transaction ;
284+
FROM clean_transaction ;
285+
286+
287+
SELECT TOP 10 * FROM bronze.sales_transactions ;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--#############################################################################
2+
-- Staging Model: src_transactions
3+
-- Purpose: Clean and deduplicate raw bronze.sales_transactions
4+
--#############################################################################
5+
6+
WITH source AS (
7+
SELECT *
8+
FROM {{ source('bronze', 'sales_transactions') }}
9+
),
10+
11+
deduplicated AS (
12+
SELECT *,
13+
ROW_NUMBER() OVER (
14+
PARTITION BY transaction_id
15+
ORDER BY transaction_id
16+
) AS _row_flag
17+
FROM source
18+
WHERE transaction_id IS NOT NULL
19+
)
20+
21+
SELECT
22+
UPPER(TRIM(transaction_id)) AS transaction_id,
23+
24+
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,
25+
26+
TRY_CAST(order_line_number AS INT) AS order_line_number,
27+
28+
CASE
29+
WHEN TRIM(order_date) LIKE '[A-Z][a-z][a-z][a-z]% __, ____' THEN TRY_CONVERT(DATE, order_date)
30+
WHEN TRIM(order_date) LIKE '[A-Z][a-z][a-z] __, ____' THEN TRY_CONVERT(DATE, order_date)
31+
WHEN TRIM(order_date) LIKE '____-__-__' THEN TRY_CONVERT(DATE, order_date)
32+
WHEN TRIM(order_date) LIKE '____/__/__' THEN TRY_CONVERT(DATE, order_date)
33+
WHEN TRIM(order_date) LIKE '__/__/____'
34+
AND TRY_CONVERT(INT, SUBSTRING(TRIM(order_date), 4, 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 101)
35+
WHEN TRIM(order_date) LIKE '__/__/____'
36+
AND TRY_CONVERT(INT, LEFT(TRIM(order_date), 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 103)
37+
WHEN TRIM(order_date) LIKE '__-__-____'
38+
AND TRY_CONVERT(INT, SUBSTRING(TRIM(order_date), 4, 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 110)
39+
WHEN TRIM(order_date) LIKE '__-__-____'
40+
AND TRY_CONVERT(INT, LEFT(TRIM(order_date), 2)) > 12 THEN TRY_CONVERT(DATE, order_date, 105)
41+
ELSE TRY_CONVERT(DATE, order_date)
42+
END AS order_date,
43+
44+
order_year, order_month, order_month_name, order_quarter, order_day_of_week,
45+
TRY_CAST(customer_id AS INT) AS customer_id,
46+
customer_full_name, customer_first_name, customer_last_name, customer_email,
47+
customer_phone, customer_city, customer_state,
48+
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,
49+
customer_region, customer_segment, customer_gender, customer_age, customer_age_group,
50+
product_id, product_name, sku, brand, category, sub_category, department,
51+
quantity_ordered,
52+
unit_list_price, discount_pct, unit_selling_price,
53+
line_total_before_tax, tax_rate_pct, tax_amount, line_total_with_tax,
54+
store_id, store_name, store_city, store_state, store_region, store_type,
55+
employee_id, employee_name, employee_job_title,
56+
promo_id, promo_name,
57+
LOWER(TRIM(sales_channel)) AS sales_channel,
58+
payment_method, shipping_method, order_status, is_returned,
59+
cost_price, gross_profit, data_source, record_created_ts, last_modified_ts
60+
FROM deduplicated
61+
WHERE _row_flag = 1;
62+
63+
-536 KB
Binary file not shown.

venv/bin/activate

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ deactivate () {
3636
deactivate nondestructive
3737

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

4848
_OLD_VIRTUAL_PATH="$PATH"
49-
PATH="$VIRTUAL_ENV/bin:$PATH"
49+
PATH="$VIRTUAL_ENV/"bin":$PATH"
5050
export PATH
5151

5252
# unset PYTHONHOME if set
@@ -59,9 +59,9 @@ fi
5959

6060
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
6161
_OLD_VIRTUAL_PS1="${PS1:-}"
62-
PS1="(venv) ${PS1:-}"
62+
PS1='(venv) '"${PS1:-}"
6363
export PS1
64-
VIRTUAL_ENV_PROMPT="(venv) "
64+
VIRTUAL_ENV_PROMPT='(venv) '
6565
export VIRTUAL_ENV_PROMPT
6666
fi
6767

venv/bin/activate.csh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA
99
# Unset irrelevant variables.
1010
deactivate nondestructive
1111

12-
setenv VIRTUAL_ENV "/workspaces/dbt_learning_project/venv"
12+
setenv VIRTUAL_ENV /home/ritik/dbt_learning_project/venv
1313

1414
set _OLD_VIRTUAL_PATH="$PATH"
15-
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
15+
setenv PATH "$VIRTUAL_ENV/"bin":$PATH"
1616

1717

1818
set _OLD_VIRTUAL_PROMPT="$prompt"
1919

2020
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
21-
set prompt = "(venv) $prompt"
22-
setenv VIRTUAL_ENV_PROMPT "(venv) "
21+
set prompt = '(venv) '"$prompt"
22+
setenv VIRTUAL_ENV_PROMPT '(venv) '
2323
endif
2424

2525
alias pydoc python -m pydoc

venv/bin/activate.fish

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ end
3333
# Unset irrelevant variables.
3434
deactivate nondestructive
3535

36-
set -gx VIRTUAL_ENV "/workspaces/dbt_learning_project/venv"
36+
set -gx VIRTUAL_ENV /home/ritik/dbt_learning_project/venv
3737

3838
set -gx _OLD_VIRTUAL_PATH $PATH
39-
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
39+
set -gx PATH "$VIRTUAL_ENV/"bin $PATH
4040

4141
# Unset PYTHONHOME if set.
4242
if set -q PYTHONHOME
@@ -56,7 +56,7 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
5656
set -l old_status $status
5757

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

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

6767
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
68-
set -gx VIRTUAL_ENV_PROMPT "(venv) "
68+
set -gx VIRTUAL_ENV_PROMPT '(venv) '
6969
end

venv/bin/daff

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)