MIT-LCP / MIT-LCP/mimic-code

`DATETIME_DIFF` implementation varies between postgres and bigquery

Open
#1,549 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
3.4k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

As raised in #1529, DATETIME_DIFF in PostgreSQL calculates a fractional number, whereas DATETIME_DIFF in BigQuery returns a whole number. This results in a subtle divergence of the concepts in the two dialects. urine_output_rate may be affected as various comparisons expected fractional values to be returned:

https://github.com/MIT-LCP/mimic-code/blob/a8308706d8f2bf3bbf42f5e7065094c648f64576/mimic-iv/concepts/measurement/urine_output_rate.sql#L44-L53

Easiest fix is to (1) update postgres-functions.sql and (2) update the UO query to take a similar approach to the kdigo_uo query.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading postgres-functions.sql and the linked lines in mimic-iv/concepts/measurement/urine_output_rate.sql, then compare the related kdigo_uo query. Align DATETIME_DIFF behavior across the PostgreSQL implementation and the urine-output query, and verify that comparisons expecting fractional values remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
63/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.