Skip to content

Commit 97c7be5

Browse files
committed
add copy concepts to version specific schema
1 parent 06f2b3b commit 97c7be5

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ name: Generate tables on BigQuery
22

33
on:
44
release:
5-
types: [published]
5+
types: [released]
6+
7+
env:
8+
MIMIC_IV_VERSION: 3_1
69

710
jobs:
811
create-tables:
@@ -24,4 +27,9 @@ jobs:
2427
run: |
2528
echo "Generating tables on BigQuery"
2629
cd mimic-iv/concepts
27-
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}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
10+
# check if the target dataset exists
11+
if bq ls | grep -q ${TARGET_DATASET}; then
12+
echo "Using existing dataset ${TARGET_DATASET}."
13+
# drop the existing tables in the target dataset
14+
# this includes ones which may not be in the source dataset
15+
for TABLE in `bq ls physionet-data:${TARGET_DATASET} | cut -d' ' -f3`;
16+
do
17+
# skip the first line of dashes
18+
if [[ "${TABLE:0:2}" == '--' ]]; then
19+
continue
20+
fi
21+
echo "Dropping table ${TARGET_DATASET}.${TABLE}"
22+
bq rm -f -q ${TARGET_DATASET}.${TABLE}
23+
done
24+
else
25+
echo "Creating dataset ${TARGET_DATASET}"
26+
bq mk --dataset ${TARGET_DATASET}
27+
fi
28+
29+
for TABLE in `bq ls physionet-data:${SOURCE_DATASET} | cut -d' ' -f3`;
30+
do
31+
# skip the first line of dashes
32+
if [[ "${TABLE:0:2}" == '--' ]]; then
33+
continue
34+
fi
35+
echo "${SOURCE_DATASET}.${TABLE} -> ${TARGET_DATASET}.${TABLE}"
36+
bq cp -f -q ${SOURCE_DATASET}.${TABLE} ${TARGET_DATASET}.${TABLE}
37+
done

0 commit comments

Comments
 (0)