Skip to content
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

Refactor to use BigQuery syntax #762

Merged
merged 50 commits into from
Jun 10, 2020
Merged

Refactor to use BigQuery syntax #762

merged 50 commits into from
Jun 10, 2020

Conversation

alistairewj
Copy link
Member

As discussed in #717, it will be easier to maintain one set of scripts rather than two branches.

I've updated all the scripts to use BigQuery syntax, and rewritten everything to be compliant to both BigQuery and PostgreSQL. BigQuery tends to do date arithmetic using purpose built functions (DATETIME_ADD, DATETIME_SUB, etc). I wrote PostgreSQL functions which emulate this functionality. Unfortunately, it's not possible to emulate DATETIME_TRUNC or DATETIME_DIFF, as these have a BigQuery primitive date unit as an argument (e.g. DATETIME_DIFF(date1, date2, HOUR)), and it's not possible to have PostgreSQL recognize anything but numeric values as a primitive in function arguments. I've worked around this by having a shell script (postgres_make_concepts.sh) which calls the functions, and it uses a regex to single quote the dateunit (i.e. HOUR -> 'HOUR'). It also changes the table names from physionet-data.mimiciii_clinical.<table> to <table>. Works well enough - though unfortunately will cause a headache for Windows psql users.

The make-concepts.sh script can be used to rebuild all the concepts on the mimiciii_derived dataset on BigQuery. The script will generate tables on whatever the default project is - for us this is physionet-data.

tompollard and others added 30 commits June 7, 2020 10:43
Kdigo_uo on Bigquery has an error in UrineOutput_6hr, UrineOutput_12hr and UrineOutput_24hr.
It is supposed to be a sum of the last 6,12,24 hours, but is a summation of the next 6,12 24 hours.
@alistairewj alistairewj merged commit b1a0ffe into master Jun 10, 2020
@alistairewj alistairewj deleted the google-cloud-views branch June 10, 2020 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants