Fix height.sql COALESCE using h1 for both args instead of h1/h2#1985
Open
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Open
Fix height.sql COALESCE using h1 for both args instead of h1/h2#1985Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Conversation
The FULL OUTER JOIN merges ht_cm (h1) and ht_in (h2), but the COALESCE for subject_id, stay_id, and charttime uses h1 as both arguments. When a patient has height charted only in inches (h2 row with no h1 match), all three columns are NULL, silently dropping the record. The height column on the next line already correctly falls back to h2. Fixed in all three dialect files (BigQuery, PostgreSQL, DuckDB). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
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.
Summary
In
height.sql, theht_stg0CTE merges height-in-cm (h1) and height-in-inches (h2) via aFULL OUTER JOIN. TheCOALESCEforsubject_id,stay_id, andcharttimeusesh1as both arguments:When a patient has height charted only in inches (itemid 226707, an
h2row with no matchingh1row), theFULL OUTER JOINproduces a row where allh1.*columns are NULL.COALESCE(NULL, NULL)yields NULL forsubject_id,stay_id, andcharttime, making the record unjoinable to any patient — silently dropping all inch-only height measurements.Fix: Change the second argument from
h1toh2in all three COALESCE calls, matching the pattern already used forheighton the next line. Applied to all three dialect files (BigQuery, PostgreSQL, DuckDB).Test plan
h2.heightas fallback🤖 Generated with Claude Code