Skip to content

Fix FULL OUTER JOIN COALESCE in MIMIC-IV height concept#2015

Merged
alistairewj merged 1 commit into
MIT-LCP:mainfrom
Chessing234:fix/mimic-iv-height-coalesce-h2
Jul 9, 2026
Merged

Fix FULL OUTER JOIN COALESCE in MIMIC-IV height concept#2015
alistairewj merged 1 commit into
MIT-LCP:mainfrom
Chessing234:fix/mimic-iv-height-coalesce-h2

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

Summary

  • Fix ht_stg0 in MIMIC-IV height.sql to use h2 columns in COALESCE fallbacks for subject_id, stay_id, and charttime
  • Apply the same fix across BigQuery, Postgres, and DuckDB concept builds

Problem

The FULL OUTER JOIN between inch-based (ht_in) and cm-based (ht_cm) height measurements used COALESCE(h1.col, h1.col), which never falls back to h2 values. Height records present only in ht_in were excluded from the derived table.

Test plan

  • Rebuild mimiciv_derived.height and verify inch-only measurements are retained
  • Compare row counts before/after on a sample MIMIC-IV install

Fixes #2010

Made with Cursor

Rows from ht_in with no matching ht_cm row were dropped because
COALESCE used h1 columns twice instead of falling back to h2.

Fixes MIT-LCP#2010.

Co-authored-by: Cursor <cursoragent@cursor.com>
@alistairewj

Copy link
Copy Markdown
Member

thanks for the fix - AFAIK this actually doesn't impact the data in the end, because those itemid have duplicate values across all rows - but it still makes sense to fix!

@alistairewj alistairewj merged commit 5bdb9a0 into MIT-LCP:main Jul 9, 2026
6 of 7 checks passed
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.

error in OUTER JOIN condition for mimic_derived.height

2 participants