Skip to content

Commit

Permalink
self review
Browse files Browse the repository at this point in the history
  • Loading branch information
dogversioning committed Dec 4, 2023
1 parent 64096b3 commit eac38ae
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 71 deletions.
18 changes: 13 additions & 5 deletions cumulus_library/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import json
import os
import sys
from functools import partial
from pathlib import Path
from typing import Optional, Protocol, Union

Expand Down Expand Up @@ -56,6 +55,14 @@ def __init__(self, schema_name: str):
def cursor(self) -> DatabaseCursor:
"""Returns a connection to the backing database"""

@abc.abstractmethod
def pandas_cursor(self) -> DatabaseCursor:
"""Returns a connection to the backing database optimized for dataframes
If your database does not provide an optimized cursor, this should function the
same as a vanilla cursor.
"""

@abc.abstractmethod
def execute_as_pandas(self, sql: str) -> pandas.DataFrame:
"""Returns a pandas.DataFrame version of the results from the provided SQL"""
Expand Down Expand Up @@ -89,11 +96,13 @@ def __init__(self, region: str, workgroup: str, profile: str, schema_name: str):
schema_name=self.schema_name,
**connect_kwargs,
)
self.pandas_cursor = self.connection.cursor(cursor=AthenaPandasCursor)

def cursor(self) -> AthenaCursor:
return self.connection.cursor()

def pandas_cursor(self) -> AthenaCursor:
return self.connection.cursor(cursor=AthenaPandasCursor)

def execute_as_pandas(self, sql: str) -> pandas.DataFrame:
return self.pandas_cursor.execute(sql).as_pandas()

Expand Down Expand Up @@ -162,9 +171,8 @@ def cursor(self) -> duckdb.DuckDBPyConnection:
return self.connection

def pandas_cursor(self) -> duckdb.DuckDBPyConnection:
# Don't actually create a new connection,
# because then we'd have to re-register our json tables.
return self.connection
# Since this is not provided, return the vanilla cursor
return self.cursor()

def execute_as_pandas(self, sql: str) -> pandas.DataFrame:
# We call convert_dtypes here in case there are integer columns.
Expand Down
11 changes: 8 additions & 3 deletions cumulus_library/statistics/psm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

@dataclass
class PsmConfig:
"""Provides expected values for PSM execution"""
"""Provides expected values for PSM execution
These values should be read in from a toml configuration file.
See tests/test_data/psm/psm_config.toml for an example with details about
the expected values for these fields.
"""

classification_json: str
pos_source_table: str
Expand All @@ -39,7 +44,7 @@ class PsmConfig:
pos_sample_size: int
neg_sample_size: int
join_cols_by_table: dict[str, dict]
seed: int = 1234567890
seed: int


class PsmBuilder(BaseTableBuilder):
Expand All @@ -48,7 +53,7 @@ class PsmBuilder(BaseTableBuilder):
display_text = "Building PSM tables..."

def __init__(self, toml_config_path: str):
"""Loads PSM job details from a psm TOML file"""
"""Loads PSM job details from a PSM configuration file"""
with open(toml_config_path, encoding="UTF-8") as file:
toml_config = toml.load(file)
self.config = PsmConfig(
Expand Down
65 changes: 3 additions & 62 deletions cumulus_library/statistics/psm.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
-- noqa: disable=all

-- This template is provided as an example only of queries generated by PSM table creation.
-- It is not used in actual validation
CREATE TABLE "cumulus_mhg_dev_db"."core__psm_cohort_sampled_ids" AS (
SELECT * FROM (
VALUES
Expand All @@ -7,68 +10,6 @@ CREATE TABLE "cumulus_mhg_dev_db"."core__psm_cohort_sampled_ids" AS (
((cast('Patient/a82d6443f6ef1e64b7542fd8d6bd8ae6fa08f525abfb2d6c212ce3a51883d8a7' AS varchar),cast('Encounter/b29ea4400966b83f380ecb8129e9939e62bcacc506b323677d70283a16ea5704' AS varchar),cast('1' AS varchar))),
((cast('Patient/3aafe05267ec191199c697a4b9c0140f11d567ca1edcd97a6a91e9e35fa6d99e' AS varchar),cast('Encounter/439122de45e8b2d124d65a88a525903ba4837dc980e6b409f866dd1eaec7962f' AS varchar),cast('1' AS varchar))),
((cast('Patient/0efd7a0cd26cae01e13fba909bcaafd445a2196117f4393c3b5f3c64245ef4c3' AS varchar),cast('Encounter/fc14df1992d4f7586914819bca5065c5b90d544e8c989be838ad8273a0bdb729' AS varchar),cast('1' AS varchar))),
((cast('Patient/50d9fbe5f3b142203529a53224539d78402912db60079df4f0811425d35125bd' AS varchar),cast('Encounter/cde5079d2d482be0cec4d3d2d1fb2b4aee4f54362c2581be8d9f7bc45a9af85f' AS varchar),cast('1' AS varchar))),
((cast('Patient/320cce52bca9cb00ff4d62fe3abc4ec7300352a595aaa7a0b2ee48e748a0d183' AS varchar),cast('Encounter/52c4f5a2eabf12e4638c71d58bd0cb2687253420aff63bd1d906245dee93bb0a' AS varchar),cast('1' AS varchar))),
((cast('Patient/3ce81e6b3b15cd26d9e9a83fa30e9373a210f0043be485f056695ebaf9368ce3' AS varchar),cast('Encounter/f01b4c4a9f270612dbd848a5db348784085c9e8e709950acc30e081bc73d5c0b' AS varchar),cast('1' AS varchar))),
((cast('Patient/882c579a63478216510dcc643be5e1553b7231a8361264d7594cbb9f648a2702' AS varchar),cast('Encounter/c0b6c2ae41ce701754fa3509b3da0a0c69887b3f2307c64325bd09ecb80b7873' AS varchar),cast('1' AS varchar))),
((cast('Patient/15961cf1f22eec6dbeba54b865a64f2b3a3006ecb0a7e335c1658eaf596e2af4' AS varchar),cast('Encounter/86a3d6f926bd78c4944e38531529c1b06683a1760565d4c75f8488b5ff4e6856' AS varchar),cast('1' AS varchar))),
((cast('Patient/bc5368114a8bdb40ea8b0a7edccd069ad80031d3431b5760a3b86e6a4392bf51' AS varchar),cast('Encounter/7d30da53d5aba36b0dd748c3d1724bcf16f500d607b778145143c25d9dd4ee22' AS varchar),cast('1' AS varchar))),
((cast('Patient/0fa4f0987fe46c657539e3cd8a816d1facffd03b9ce7112e546fadc73744cad7' AS varchar),cast('Encounter/31702d82108744d3c3237af26c4dfb05cb43a418d1848e942845a17a301f2348' AS varchar),cast('1' AS varchar))),
((cast('Patient/bc8118df3cc6fa0b285f509fab0462bf3a209f02afb5bf4cbb5a3c899ecd69e1' AS varchar),cast('Encounter/a1daaa4a62db8a906e8e736758d67ec3a4e9bc2aea86d42873f4b8b5c5ddd72b' AS varchar),cast('1' AS varchar))),
((cast('Patient/f642ad9efcef7fd58fedef30b8c07359d0c85e591f100dcc8377efad28a40b01' AS varchar),cast('Encounter/a7c013f15a8467982a21873330c9d62c2baa4631544655cc3cd1566ff063487c' AS varchar),cast('1' AS varchar))),
((cast('Patient/222f2355b10bc39bc9a9ded1ade0de8850b0af922e146b283a8d9df88469d7a0' AS varchar),cast('Encounter/4b11b7264ada1a8623048073243624979111ac81ce1128bb479b6800fa11fa90' AS varchar),cast('1' AS varchar))),
((cast('Patient/b43c0a1d9273c8d4fc1b2161c5d26b1bcf6ceb9bcfe225f0b5f7b9983159f716' AS varchar),cast('Encounter/431ffa9723a074a69f27e1ef4a9351587537665894a33cc8d789281f73ef7942' AS varchar),cast('1' AS varchar))),
((cast('Patient/aaa7627e62c99312fceef021302d48989a9a924ed9ac231f4656a5fd29ebfd26' AS varchar),cast('Encounter/1f024866da15f33d46a5a47f8205fc3ec0f4740ac7f28a88b6f219972388904a' AS varchar),cast('1' AS varchar))),
((cast('Patient/ef85aff307071e783f17f0d42104fab8b19381c75ebc37d2d1b234fc4c4d74fe' AS varchar),cast('Encounter/ad3927be7a61b576ba6dc9e52c544df4e3a26aae513d17142a864f4315826583' AS varchar),cast('1' AS varchar))),
((cast('Patient/b43c0a1d9273c8d4fc1b2161c5d26b1bcf6ceb9bcfe225f0b5f7b9983159f716' AS varchar),cast('Encounter/d73c40e2ce6ec09d79fe4ad59d7f5cebf96af8db5c7cc54cc2086f8e186941d3' AS varchar),cast('1' AS varchar))),
((cast('Patient/b94aaae0b0a3ac7d91d0932c45454f7c86fec10c0e9ed685c4aad1f07cac570e' AS varchar),cast('Encounter/647e552513b9ab28e17172eb845755b8bc53e0244a649c7336851ad9334c2696' AS varchar),cast('1' AS varchar))),
((cast('Patient/3df91db3c381bbdcfbea57bafdfe767098a77b75bdaefa73c30c3858fee67d0d' AS varchar),cast('Encounter/93d3bead1cf65fa4b4894b8615a95fe209b8fa99be8063e47b8755c6d8ceba42' AS varchar),cast('0' AS varchar))),
((cast('Patient/ffcc85457a71630f8dedc905a6cf023e8009ff5efd938912fb5a5ceb845baef3' AS varchar),cast('Encounter/8cceb04ed38d8f2bda250a7c395b6600a8732b67d529eb18667378a561e1f296' AS varchar),cast('0' AS varchar))),
((cast('Patient/8abce4d5b0dccae9ec56f6a6bf6ae24d7ffd83b2b51d951fe8b020ad29dc651a' AS varchar),cast('Encounter/fbd75ddcc9da85b96335e728e2494f1a42483c68e32b5bd793f5491419f8b60d' AS varchar),cast('0' AS varchar))),
((cast('Patient/98e1dcad658f0d3ed713a77a3c4112ea3a21df316133c10b3151beb94ca3f5d6' AS varchar),cast('Encounter/bf760964ae2791399aaee56bd843aade0a37fbdf51117bbb8146aedead368ef3' AS varchar),cast('0' AS varchar))),
((cast('Patient/75164294583880de42729d580678f3369052fbce2dd73a830bcdb8ea0fe1c37b' AS varchar),cast('Encounter/f82785991a0c447465f11f6c597abc996b16b948acc963a3758dc12cced483b8' AS varchar),cast('0' AS varchar))),
((cast('Patient/fb13358126930ba503941673c6e391e3b480e2bf9a02c553544f35245e2c1524' AS varchar),cast('Encounter/e78a58870f16e5a669fea86eea36948c3c2f002cd5c2a1bac485c806c8c7d9f5' AS varchar),cast('0' AS varchar))),
((cast('Patient/e122df8065e1be221a4be8fd83e5aab0df9de956bdc9a33c95be8a87b7ecb7fd' AS varchar),cast('Encounter/0455c2966f1fc4790fdda94091e4b07acb06ca9e133ee8421bc5141d3ac34e28' AS varchar),cast('0' AS varchar))),
((cast('Patient/48bdb2af6fcf82cf726bb32489e2df57395c4ea20329e71f5bca964db6158cd2' AS varchar),cast('Encounter/bc113669f5a7cf61575b9cb26b75439241aebfabe199d09f835ec7dc0aab4420' AS varchar),cast('0' AS varchar))),
((cast('Patient/09353bd6e097f59e51e5a113dbc388c2913a67adad3d257a9b672152db536b38' AS varchar),cast('Encounter/6b5fae7aa1e1f5b3601c5ba9e635c3ce71845648cad2962ce645039b0bbcf20e' AS varchar),cast('0' AS varchar))),
((cast('Patient/9c1ed4fe0d350e90a015ad98ed40b29a702790401dd9072ad7694de2e6454935' AS varchar),cast('Encounter/407246eaba3f85f5c0cc95f4a544656e5a918f910fbd264a60206b0ec880837b' AS varchar),cast('0' AS varchar))),
((cast('Patient/81d3c8642600779be157e4e7eed5026c3b9fff3b8e4edda2bdbd56e49ed8fabb' AS varchar),cast('Encounter/96c373509c2d1d3d3347af58b894b35346ff1b89fd853dd5f758ce624ccb8f51' AS varchar),cast('0' AS varchar))),
((cast('Patient/e72f646baa605ed5d451859924d38bd1410f7e2cf5e7d52db6d0a4da01ecc496' AS varchar),cast('Encounter/37cdbcbd7d7f37c4298b153433524365fcddee35abdd882fb23395c53964d3d9' AS varchar),cast('0' AS varchar))),
((cast('Patient/1a862a2288a4af65bed371c3926a91a88d7fb8cfe04e9a457d2674a8285fda83' AS varchar),cast('Encounter/396107165e308c599b4717ba5f1f0c433aa1d67ed92250eba24b4685db8669c0' AS varchar),cast('0' AS varchar))),
((cast('Patient/72e6e9272902e39dbfd91aae3ac8f43929057fc4f0119fca826df8e468723488' AS varchar),cast('Encounter/b572f3d0e66722fc830cbd7750d4d702c67f7e2b6ea5838cfcaf18fe8a8fbf92' AS varchar),cast('0' AS varchar))),
((cast('Patient/d22ebd757231d633594987fd8968bb34c4014a462613d66e57cb40b577e70734' AS varchar),cast('Encounter/a816500ecc5e4065c8cc89cd15df23f3f270f597baa6e6753afb647fd6a2de65' AS varchar),cast('0' AS varchar))),
((cast('Patient/eead3f673bdaca10f12ceca63f1814fe8d528c3d9e2cfff99754a435ffab93f1' AS varchar),cast('Encounter/e3f35454c976ab35a7187c8069765ce26903e25660511cd2f7153aefb20f4d91' AS varchar),cast('0' AS varchar))),
((cast('Patient/644ba99b38f92c0b41de2e3dfd95f83623718999f2ea5fc3a55e3c441200599b' AS varchar),cast('Encounter/fb80129e4cf335bd6f9ae459f868409d7a5041ef49df14eb0e4f60c9a9a5546b' AS varchar),cast('0' AS varchar))),
((cast('Patient/a50737315a9b5d74573be547a93de304072070fd9851da0429c9eb68398eebf4' AS varchar),cast('Encounter/f2f328c162cccddc3e5f984a5526e9b38fad7ca03607f8d68e97ee1125b6589d' AS varchar),cast('0' AS varchar))),
((cast('Patient/aaa7627e62c99312fceef021302d48989a9a924ed9ac231f4656a5fd29ebfd26' AS varchar),cast('Encounter/167c79720b8bc5dace5aa469f1e44b6010c3268677b6c27da2e554cdbd2fe903' AS varchar),cast('0' AS varchar))),
((cast('Patient/a4cc07e6f913e52dbf19d4cd04e075841ed3a2c7e4ead3768653aefee20550d6' AS varchar),cast('Encounter/9c71ff5ce943d68ea0a357e74949891d3587a96d5c5658e534678398c37d28fe' AS varchar),cast('0' AS varchar))),
((cast('Patient/e2f4ab84647ec23b988a7c99c6118e9d4fb9d243d0e53effa611b2386c9ed2c1' AS varchar),cast('Encounter/97ee812b1916a134a6ea9a9848c2a5696b8dbf09cad5a408d3b174ae6853ff30' AS varchar),cast('0' AS varchar))),
((cast('Patient/841127bf03ccfce622dcce934fad77aa32abe9c606ce01248bf2eff04eefe1b4' AS varchar),cast('Encounter/1db1d61a14a6ef022d5d1d17b92a6e21ac03b0e189040a26e9051892fa51fe65' AS varchar),cast('0' AS varchar))),
((cast('Patient/478ac40c9feea40cbe94cf25d493ecc7e4036cfe376256159f7c8ba27990661e' AS varchar),cast('Encounter/1271c2f2740c0bbb962fd2a851cbbe3a7f4c5883bff5a4b193317c38eae912f5' AS varchar),cast('0' AS varchar))),
((cast('Patient/4201e61c1698b62091c78000f9850143a9179446e966d9d45a5eb0d783eb38e4' AS varchar),cast('Encounter/bc5be6306ac7e2fe796b55dcac7ab40a7687de52afe97d0ea9c6524b3d48ae74' AS varchar),cast('0' AS varchar))),
((cast('Patient/00ce22d5bb5cae09c5942135c34c61660882ec658ecd78677a8dc43b77425073' AS varchar),cast('Encounter/8371856539df760e7cf25cf9171701d4e94501fef6fc10a40c81680936116ea0' AS varchar),cast('0' AS varchar))),
((cast('Patient/644ba99b38f92c0b41de2e3dfd95f83623718999f2ea5fc3a55e3c441200599b' AS varchar),cast('Encounter/ec8d34043223974ef89abdce1cfa58c77710463a5b37baeebc2fc99d822d4f3c' AS varchar),cast('0' AS varchar))),
((cast('Patient/e82e2afddb937682feeba017d5feccb488ee766ac50e1cda0d300725bc0ed983' AS varchar),cast('Encounter/55f08e011e60574906b692479460bbddd275a15d273bae40c662dfd30a848280' AS varchar),cast('0' AS varchar))),
((cast('Patient/8a486e85a8faa75adcef0a684975b1c4a0d457b2787e31d7fe1a105cac231846' AS varchar),cast('Encounter/6afbc0dea2b609d1b7f724e5c12b743d65d12cd4c36f533ab29679f4dc4b0912' AS varchar),cast('0' AS varchar))),
((cast('Patient/1f3f71df4383551b5c7ad5884a4baf098675d78bc3355a6a714ae20313c0934f' AS varchar),cast('Encounter/4bb11bd4187c8b0c3d79fb6153e2fe16e6645da62096da4712dc0b01dde30cd6' AS varchar),cast('0' AS varchar))),
((cast('Patient/b7d8ac2e9432a829d977610d16063517ed1094ccc31c8bde5b34ef728d3fdf4f' AS varchar),cast('Encounter/38d139174da0e9360a474204ce77a3ec661cdadd0759777e0ab79c57f5ed1c2a' AS varchar),cast('0' AS varchar))),
((cast('Patient/f8984e87c035d43fbf8aadc4616244e043fb2ed22121a16432bb7f201b0038c2' AS varchar),cast('Encounter/0f67621c010ebb0f10c7d55877fb03b4c4796dc25d2434b548c002c513cd568f' AS varchar),cast('0' AS varchar))),
((cast('Patient/008ba32814086d4d030b5dce1c1248b2551fcefe7efd7cee21121c699aa22a0d' AS varchar),cast('Encounter/ead78d05b8c3342717cc56836063bcaccef9d9a5b2de2ed93dac50232c272f0b' AS varchar),cast('0' AS varchar))),
((cast('Patient/941498945fdc323dbf18fd1b25552ec8a31801d306e63c1899946bfeed582c38' AS varchar),cast('Encounter/97e5ab4888251fdb8c9ac5defe7bc80aef32e405730e934ac8dc197bdb09c1d3' AS varchar),cast('0' AS varchar))),
((cast('Patient/bdb91ea213cde98ab2e987417376a9a9d1b0abf2367b0c22ddfb6a149d1003d2' AS varchar),cast('Encounter/06ff3ff4021dfa32a984cad3781e6ff0877acc5238a651fba0c96cb340e27e67' AS varchar),cast('0' AS varchar))),
((cast('Patient/9ac438286b83a9daee6c391f855ba434184c193b4653679f002318b9d01a6eb1' AS varchar),cast('Encounter/ffae8ce81cdf025ebb0930e87e0cbfe487498b29d552bfa9559ef80ffc4853eb' AS varchar),cast('0' AS varchar))),
((cast('Patient/dc8856faa2091d73b687f4aa982402692d7cf56c4ed129404fbecf1faf54e9b0' AS varchar),cast('Encounter/cd52f1c3ee14383e4f3c84768b9d57e233994d310f91960f0d9666355fb5f44c' AS varchar),cast('0' AS varchar))),
((cast('Patient/276e068ce8463e6dd018eca0d2684c928fe69b1a191d966ff3c70b10244310e0' AS varchar),cast('Encounter/cfdb52394c8d9f66e8f1479e352770fc23c76e1d1ba37d80b515e48105ae3e5d' AS varchar),cast('0' AS varchar))),
((cast('Patient/c79c91e1346140dd41bbe8da9cf9d3b162bd23b42f0ab9d11d7901a11f61e18c' AS varchar),cast('Encounter/34e173220edae20dfb261c580043cdc69afc70d2875101ce837858ca829c52ef' AS varchar),cast('0' AS varchar))),
((cast('Patient/e2f4ab84647ec23b988a7c99c6118e9d4fb9d243d0e53effa611b2386c9ed2c1' AS varchar),cast('Encounter/714a684cc1c57bcd2db8216883154b5543293978de149980ee0b0f443d55036c' AS varchar),cast('0' AS varchar))),
((cast('Patient/8be278520c87cfde67943413692a0ab4ba40c3a38635cdb87b93340469b55667' AS varchar),cast('Encounter/ed9a425b1edc208675dbe4e4d6cddfb7a12bc87dd081d619692ebc51c2d88bad' AS varchar),cast('0' AS varchar))),
((cast('Patient/e23a56d527cda94fada9ebbe3f22413a1a31d82a04f6bb7d416021d35cfbffff' AS varchar),cast('Encounter/1fef0390b1a172285298953f412a0f35b552bcd37cc2e6e4403b10d233ae1953' AS varchar),cast('0' AS varchar))),
((cast('Patient/61042fa86aa2b12a2f0d984051f70569c75494933524816ec3b0255b1a5ca4fd' AS varchar),cast('Encounter/a5c9bb6ad3644435f4c0e907b486a11a1eeef35c2bf4bc1266e26eca86c0e4d1' AS varchar),cast('0' AS varchar))),
((cast('Patient/aaa7627e62c99312fceef021302d48989a9a924ed9ac231f4656a5fd29ebfd26' AS varchar),cast('Encounter/3613943bada30261ac8896543a5f85944ddd423745ed2f6d5db674213b1412f7' AS varchar),cast('0' AS varchar))),
((cast('Patient/8070692627a5b08d6090e2585907634773d24043580d38353d8457c339a7cafc' AS varchar),cast('Encounter/33f6e5b15a65538e32012009b19b42cb6d2a6e430b57c13d8f118729a22654b9' AS varchar),cast('0' AS varchar))),
((cast('Patient/56fa59b0f19b6b6d19a472313b78e355d8bd71ec8bbe0a8d1cb32ee966b64850' AS varchar),cast('Encounter/6aa1753de47c16f898b24c97c303ab5a2a2d1f1cfa7b0428a499a379d0d7166b' AS varchar),cast('0' AS varchar))),
((cast('Patient/7131387ace7c425de78ebeba287a67436ff3e9025c9b18d21d3d7af8a8dd0f1e' AS varchar),cast('Encounter/aec3e626a1b9ac93377f99765f09249476fc6ee6659db552482fbf25e15cdae0' AS varchar),cast('0' AS varchar))),
((cast('Patient/3bae77ef7c1834c9ac99900a4d101aac1c40e2e741ebeae6d6a9975241d66913' AS varchar),cast('Encounter/df966a2c8069a6c83483681224ab2406e73e3b36090b42bb085eb7dd04814ae8' AS varchar),cast('0' AS varchar))),
((cast('Patient/564a3c168f33783e76ce60b1dcf05f1eb9857c1d2459e729819ed45174bfa1c1' AS varchar),cast('Encounter/a2ed39553b6014205d3199dc9968f34d4ad2318d34dbb413475e7c430feeabf1' AS varchar),cast('0' AS varchar))),
((cast('Patient/7229f84324dc9eb4e92ac1c483f7307d984a9e2ab9f4d8db098c919629be4f2f' AS varchar),cast('Encounter/6b2f6ef2495d772416abd254504db3fa1c8f2ac13c50f926c25ba280f1b4924d' AS varchar),cast('0' AS varchar))),
((cast('Patient/fd32b483921f8c16d0127e9c7f5af3112a973d304fc1ce335b70e439741c8004' AS varchar),cast('Encounter/4cab98a3f5c6ba9439285e19a6ecba6bc50083f613700f992511dc57a572ddcb' AS varchar),cast('0' AS varchar))),
Expand Down
Binary file removed cumulus_mhg_dev_db
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def mock_db():

@pytest.fixture
def mock_db_core():
"""Provides a DuckDatabaseBackend with the core study ranfor local testing"""
"""Provides a DuckDatabaseBackend with the core study ran for local testing"""
data_dir = f"{Path(__file__).parent}/test_data/duckdb_data"
with tempfile.TemporaryDirectory() as tmpdir:
db = create_db_backend(
Expand Down
Binary file removed tests/test_data/duckdb_data/Untitled
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
""" tests for jinja sql templates """
import pytest

from pandas import DataFrame

from cumulus_library.template_sql.templates import (
CodeableConceptConfig,
ExtensionConfig,
Expand All @@ -10,6 +13,7 @@
get_count_query,
get_create_view_query,
get_ctas_query,
get_ctas_query_from_df,
get_extension_denormalize_query,
get_insert_into_query,
get_is_table_not_empty_query,
Expand Down Expand Up @@ -380,6 +384,12 @@ def test_ctas_query_creation():
table_cols=["a", "b"],
)
assert query == expected
query = get_ctas_query_from_df(
schema_name="test_schema",
table_name="test_table",
df=DataFrame({"a": ["foo", "bar"], "b": ["foo", "bar"]}),
)
assert query == expected


def test_extension_denormalize_creation():
Expand Down

0 comments on commit eac38ae

Please sign in to comment.