-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
WITH expected AS | ||
( | ||
SELECT 'discharge' AS tbl, 331793 AS row_count UNION ALL | ||
SELECT 'radiology' AS tbl, 2321355 AS row_count UNION ALL | ||
SELECT 'discharge_detail' AS tbl, 186138 AS row_count UNION ALL | ||
SELECT 'radiology_detail' AS tbl, 6046121 AS row_count | ||
) | ||
, observed as | ||
( | ||
SELECT 'discharge' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.discharge UNION ALL | ||
SELECT 'radiology' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.radiology UNION ALL | ||
SELECT 'discharge_detail' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.discharge_detail UNION ALL | ||
SELECT 'radiology_detail' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.radiology_detail | ||
) | ||
SELECT | ||
exp.tbl | ||
, exp.row_count AS expected_count | ||
, obs.row_count AS observed_count | ||
, CASE | ||
WHEN exp.row_count = obs.row_count | ||
THEN 'PASSED' | ||
ELSE 'FAILED' | ||
END AS ROW_COUNT_CHECK | ||
FROM expected exp | ||
INNER JOIN observed obs | ||
ON exp.tbl = obs.tbl | ||
ORDER BY exp.tbl | ||
; |