Skip to content

Add scripts extract and transform the #120

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

Closed
wants to merge 8 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@
3. `python upload-survey-cake-csv-to-bigquery.py --year=<20xx> -c <name of contributor>`
1. it would upload data to Bigquery's `test` dataset
2. If everything looks good, you can `copy` the `fact table` and `dimension table` first
3. Then run `python upload-survey-cake-csv-to-bigquery.py --year=<20xx> -p`. `-p` stands for `production`
3. Then run `python upload-survey-cake-csv-to-bigquery.py --year=<20xx> -p`. `-p` stands for `production`

## KKTIX BigQuery Transform
1. Background: Start from 2022, we extract the KKTIX data via KKTIX API and load to "pycontw-225217.ods.ods_kktix_attendeeId_datetime". However most of the data are store in the ATTENDEE_INFO column with json format. To use metabase with SQL, users need to extract the data by json_extract with the knowledge kktix format instead of flat database. And we also need to rewrite all the SQLs build for current databases.
2. Solution: Transform the tables in backend that we could keep the same user experience by using Metabase.
3. Run:
- for 3 tables in single bash script: `./kktix_bq_etl.sh 2023`
15 changes: 15 additions & 0 deletions contrib/kktix_bq_etl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# export GOOGLE_APPLICATION_CREDENTIALS="<where to access service-account.json>"
#
project_id="pycontw-225217"
cmd=${PWD}/../dags/ods/kktix_ticket_orders/udfs/kktix_bq_dwd_etl.py


for ticket_type in corporate individual reserved
do
suffix=${ticket_type}_attendees$2
cmd_args="-p ${project_id} -d dwd -t kktix_ticket_${suffix} -k ${ticket_type} -y $1 --upload"
echo ${cmd_args}
${cmd} ${cmd_args}
done
Loading