-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 emulateDATETIME_TRUNC
orDATETIME_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 fromphysionet-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 isphysionet-data
.