-
Notifications
You must be signed in to change notification settings - Fork 2
/
seed-bigquery.sh
49 lines (42 loc) · 2.29 KB
/
seed-bigquery.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
echo "\033[33m🚀 Running all scripts\033[0m"
echo ""
echo ""
echo "1. update start date to 200 days ago"
date_two_hundreed_days_ago=$(/bin/date -j -v-200d "+%Y-%m-%d %H:%M:%S")
for file in synth/*.json; do
sed -i '' "s/\"start\": \"[^\"]*\"/\"start\": \"$date_two_hundreed_days_ago\"/" $file
done
# echo in green that it's done and add a newlines
echo "\033[32m✅ Done updating start date to 200 days ago\033[0m"
echo ""
echo ""
echo "2. running synths"
synth generate synth --collection users > synth_output_data/users.json
synth generate synth --collection orders > synth_output_data/orders.json
synth generate synth --collection partners > synth_output_data/partners.json
synth generate synth --collection products > synth_output_data/products.json
synth generate synth --collection support_requests > synth_output_data/support_requests.json
synth generate synth --collection orders --random > synth_output_data/orders_random.json
synth generate synth --collection support_requests --random > synth_output_data/support_requests_random.json
echo "\033[32m✅ Done running synths\033[0m"
echo ""
echo ""
echo "3. transform data"
python main.py --path dbt-bigquery
echo "\033[32m✅ Done transforming data\033[0m"
echo ""
echo ""
echo "4. load data to bigquery"
bq load --autodetect=true --replace=true --schema=dbt-bigquery/seeds/users.json lightdash_demo_gardening.users dbt-bigquery/seeds/users.csv
bq load --autodetect=true --replace=true --schema=dbt-bigquery/seeds/orders.json lightdash_demo_gardening.orders dbt-bigquery/seeds/orders.csv
bq load --autodetect=true --replace=true --schema=dbt-bigquery/seeds/baskets.json lightdash_demo_gardening.baskets dbt-bigquery/seeds/baskets.csv
bq load --autodetect=true --replace=true --schema=dbt-bigquery/seeds/partners.json lightdash_demo_gardening.partners dbt-bigquery/seeds/partners.csv
bq load --autodetect=true --replace=true --schema=dbt-bigquery/seeds/products.json lightdash_demo_gardening.products dbt-bigquery/seeds/products.csv
bq load --autodetect=true --replace=true --schema=dbt-bigquery/seeds/support_requests.json lightdash_demo_gardening.support_requests dbt-bigquery/seeds/support_requests.csv
echo "\033[32m✅ Done loading data to bigquery\033[0m"
echo ""
echo ""
echo "5. ℹ️ You need to run DBT manually to update the tables!"
echo ""
echo ""