File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ name: Generate tables on BigQuery
22
33on :
44 release :
5- types : [published]
6- branches : ["main"]
5+ types : [released]
6+
7+ env :
8+ MIMIC_IV_VERSION : 3_1
79
810jobs :
911 create-tables :
2527 run : |
2628 echo "Generating tables on BigQuery"
2729 cd mimic-iv/concepts
28- bash make_concepts.sh
30+ bash make_concepts.sh
31+
32+ - name : Copy to release specific schema
33+ run : |
34+ echo "Copying tables to release specific schema: mimiciv_${MIMIC_IV_VERSION}_derived"
35+ bash mimic-iv/concepts/copy_concepts_to_versioned_schema.sh ${MIMIC_IV_VERSION}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # This script copies the concepts in the BigQuery table mimiciv_derived to mimiciv_${VERSION}_derived.
3+ if [ -z " $$ 1" ]; then
4+ echo " Usage: $0 <version>"
5+ exit 1
6+ fi
7+ export SOURCE_DATASET=mimiciv_derived
8+ export TARGET_DATASET=mimiciv_$1 _derived
9+ export PROJECT_ID=physionet-data
10+
11+ # check if the target dataset exists
12+ if bq ls --datasets --project_id ${PROJECT_ID} | grep -q ${TARGET_DATASET} ; then
13+ echo " Using existing dataset ${TARGET_DATASET} ."
14+ # drop the existing tables in the target dataset
15+ # this includes ones which may not be in the source dataset
16+ for TABLE in ` bq ls ${PROJECT_ID} :${TARGET_DATASET} | cut -d' ' -f3` ;
17+ do
18+ # skip the first line of dashes
19+ if [[ " ${TABLE: 0: 2} " == ' --' ]]; then
20+ continue
21+ fi
22+ bq rm -f -q ${PROJECT_ID} :${TARGET_DATASET} .${TABLE}
23+ done
24+ else
25+ echo " Creating dataset ${PROJECT_ID} :${TARGET_DATASET} "
26+ bq mk --dataset ${PROJECT_ID} :${TARGET_DATASET}
27+ fi
28+
29+ echo " Copying tables from ${SOURCE_DATASET} to ${TARGET_DATASET} ."
30+ for TABLE in ` bq ls ${PROJECT_ID} :${SOURCE_DATASET} | cut -d' ' -f3` ;
31+ do
32+ # skip the first line of dashes
33+ if [[ " ${TABLE: 0: 2} " == ' --' ]]; then
34+ continue
35+ fi
36+ bq cp -f -q ${PROJECT_ID} :${SOURCE_DATASET} .${TABLE} ${PROJECT_ID} :${TARGET_DATASET} .${TABLE}
37+ done
Original file line number Diff line number Diff line change @@ -6,6 +6,17 @@ export TARGET_DATASET=mimiciv_derived
66# note: max_rows=1 *displays* only one row, but all rows are inserted into the destination table
77BQ_OPTIONS=' --quiet --headless --max_rows=0 --use_legacy_sql=False --replace'
88
9+ # drop the existing tables in the target dataset
10+ for TABLE in ` bq ls physionet-data:${TARGET_DATASET} | cut -d' ' -f3` ;
11+ do
12+ # skip the first line of dashes
13+ if [[ " ${TABLE: 0: 2} " == ' --' ]]; then
14+ continue
15+ fi
16+ echo " Dropping table ${TARGET_DATASET} .${TABLE} "
17+ bq rm -f -q ${TARGET_DATASET} .${TABLE}
18+ done
19+
920# generate a few tables first as the desired order isn't alphabetical
1021for table_path in demographics/icustay_times;
1122do
You can’t perform that action at this time.
0 commit comments