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

Problems with the convert_bigquery_to_postgres.sh script #1393

Closed
1 task done
marceliwac opened this issue Sep 25, 2022 · 2 comments
Closed
1 task done

Problems with the convert_bigquery_to_postgres.sh script #1393

marceliwac opened this issue Sep 25, 2022 · 2 comments

Comments

@marceliwac
Copy link
Contributor

marceliwac commented Sep 25, 2022

Prerequisites

Description

There are few problems with the conversion to postgres using the convert_bigquery_to_postgres.sh which render the created SQL scripts partially broken (some scripts fail while others proceed).


  1. The script does not replace the ROUND statement correctly. More specifically, the regex appears to treat the next sequence of characters up until whitespace as the group to enclose in the brackets, and not the next "token/statement" if that makes sense.

That results in the following:

, ROUND(DATETIME_DIFF(ie.outtime, ie.intime, HOUR)/24.0, 2) as los_icu

being replaced to:

, ROUND( CAST( DATETIME_DIFF(ie.outtime as numeric),ie.intime, 'HOUR')/24.0, 2) as los_icu

instead of:

, ROUND( CAST( DATETIME_DIFF(ie.outtime, ie.intime, 'HOUR') as numeric) /24.0, 2) as los_icu
---   the " as numeric)"               ^ instead of here   ^ should go here

  1. The script also does not replace the date-parts (YEAR, MONTH etc.) for the function call to DATETIME with its quotemark-encapsulated counterparts. This is currently done for DATETIME_DIFF and DATETIME_TRUNC, but not DATETIME, which is needed by Postgres.

That results in the following:

, DATETIME_DIFF(adm.admittime, DATETIME(pat.anchor_year, 1, 1, 0, 0, 0), YEAR) + pat.anchor_age as admission_age

being replaced to:

, DATETIME_DIFF(adm.admittime, DATETIME(pat.anchor_year, 1, 1, 0, 0, 0), YEAR) + pat.anchor_age as admission_age

instead of:

, DATETIME_DIFF(adm.admittime, DATETIME(pat.anchor_year, 1, 1, 0, 0, 0), 'YEAR') + pat.anchor_age as admission_age
---                                         add missing quotemarks here  ^    ^

  1. The script in mimic-iv/concepts/postgres/measurement/oxygen_delivery.sql uses mimic_icu.chartevents instead of mimiciv_icu.chartevents.
@marceliwac
Copy link
Contributor Author

marceliwac commented Sep 25, 2022

For your convenience, here is a temporary patch of changes that make the scripts in mimic-iv/concepts/postgres usable again.

fix_conversion_problems.patch (txt)

@alistairewj
Copy link
Member

I think this is all fixed now, so I will close it, but feel free to reopen if I missed something. Thanks for raising the issue!

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

No branches or pull requests

2 participants