Skip to content

Commit 7394f24

Browse files
committed
copy indexes onto temp table for pa only + some clean up
1 parent 8be87e6 commit 7394f24

6 files changed

Lines changed: 14 additions & 21 deletions

File tree

apps/bfd-pipeline-idr/load-synthetic-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ if [[ -n "$1" ]]; then
4646
args+=('--seed-from' "$1")
4747
fi
4848

49-
IDR_ENABLE_DATE_PARTITIONS=0 IDR_ENABLE_PRIOR_AUTH=1 uv run pipeline.py "${args[@]}"
49+
IDR_ENABLE_DATE_PARTITIONS=0 uv run pipeline.py "${args[@]}"

apps/bfd-pipeline-idr/loader.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ async def _mark_batch_complete(self, cur: psycopg.AsyncCursor) -> None:
333333
)
334334

335335
async def _setup_temp_table(
336-
self, cur: psycopg.AsyncCursor[Any], suffix: str | None = None
336+
self, cur: psycopg.AsyncCursor[Any], suffix: str | None = None, copy_indexes: bool = False
337337
) -> str:
338338
# Load each batch into a temp table
339339
# This is necessary because we want to use COPY to quickly
@@ -345,8 +345,9 @@ async def _setup_temp_table(
345345
# For simplicity's sake, we'll create our temp tables using the existing schema and
346346
# just drop the columns we need to ignore.
347347
full_tablename = f"{self.temp_table}_{suffix or ''}"
348+
copy_indexes_option = "INCLUDING INDEXES" if copy_indexes else ""
348349
await cur.execute(
349-
f'CREATE TEMPORARY TABLE "{full_tablename}" (LIKE {self.table}) ' # type: ignore
350+
f'CREATE TEMPORARY TABLE "{full_tablename}" (LIKE {self.table} {copy_indexes_option}) ' # type: ignore
350351
"ON COMMIT DROP"
351352
)
352353
# Created/updated columns don't need to be loaded from the source.
@@ -450,7 +451,7 @@ async def load(self) -> bool:
450451

451452
async with self.pool.connection() as conn, conn.cursor(binary=True) as cur:
452453
await self._record_batch_start(conn, cur, commit=False)
453-
full_temp_table = await self._setup_temp_table(cur, "full_temp")
454+
full_temp_table = await self._setup_temp_table(cur, "full_temp", True)
454455

455456
num_rows = await self._stage_all_batches(
456457
functools.partial(self._copy_data, cur, full_temp_table)

apps/bfd-pipeline-idr/run-db.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function do_load() {
2121
BFD_DB_PASSWORD="$DB_PASSWORD" \
2222
BFD_DB_ENDPOINT="$DB_ENDPOINT" \
2323
IDR_ENABLE_DATE_PARTITIONS=0 \
24-
IDR_ENABLE_PRIOR_AUTH=1 \
2524
uv run pipeline.py \
2625
--source postgres \
2726
--load-mode synthetic \

apps/bfd-pipeline-idr/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def bfd_test_date() -> datetime | None:
2727

2828

2929
def enable_prior_auth_ingestion() -> bool:
30-
return _parse_bool_default_false("IDR_ENABLE_PRIOR_AUTH")
30+
return _parse_bool_default_true("IDR_ENABLE_PRIOR_AUTH")
3131

3232

3333
ENABLE_DATE_PARTITIONS = _parse_bool_default_true("IDR_ENABLE_DATE_PARTITIONS")

apps/bfd-pipeline-idr/test_pipeline.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from model.base_model import LoadMode, Source
2727
from pipeline import run
2828
from pydantic_utils import fields
29-
from settings import enable_prior_auth_ingestion
3029

3130
# ryuk throws a 500 or 404 error for some reason
3231
# seems to have issues with podman https://github.com/testcontainers/testcontainers-python/issues/753
@@ -82,16 +81,15 @@ def _do_test_pipeline(conn: Connection[DictRow], load_type: LoadType) -> None:
8281
rows = cur.fetchmany(1)
8382
assert rows[0]["bene_xref_efctv_sk"] == 353816021
8483

85-
if enable_prior_auth_ingestion():
86-
cur = conn.execute("select * from idr.prior_auth order by mbi_num")
87-
assert cur.rowcount == 21
88-
rows = cur.fetchmany(1)
89-
assert rows[0]["mbi_num"] == "1OX4Y88RV68"
84+
cur = conn.execute("select * from idr.prior_auth order by mbi_num")
85+
assert cur.rowcount == 21
86+
rows = cur.fetchmany(1)
87+
assert rows[0]["mbi_num"] == "1OX4Y88RV68"
9088

91-
cur = conn.execute("select * from idr.prior_auth_item order by mbi_num")
92-
assert cur.rowcount == 64
93-
rows = cur.fetchmany(1)
94-
assert rows[0]["mbi_num"] == "1OX4Y88RV68"
89+
cur = conn.execute("select * from idr.prior_auth_item order by mbi_num")
90+
assert cur.rowcount == 64
91+
rows = cur.fetchmany(1)
92+
assert rows[0]["mbi_num"] == "1OX4Y88RV68"
9593

9694
cur = conn.execute("select max(last_ts) as max_ts from idr.load_progress")
9795
row = cur.fetchone()
@@ -546,9 +544,6 @@ def _do_test_pipeline(conn: Connection[DictRow], load_type: LoadType) -> None:
546544

547545

548546
def _do_test_prior_auth_update_and_delete(conn: Connection[DictRow], load_type: LoadType) -> None:
549-
if not enable_prior_auth_ingestion():
550-
return
551-
552547
cur = conn.execute(
553548
"select * from idr.prior_auth where mbi_num = '7ZM6HW2AT68' and utn = '-OTENCJLOQRAKA'"
554549
)
@@ -676,7 +671,6 @@ def _setup_pipeline_environment(info: psycopg.ConnectionInfo) -> None:
676671
os.environ["BFD_TEST_DATE"] = "2023-04-02"
677672
os.environ["IDR_PER_BATCH_MIN_CONNECTIONS"] = "1"
678673
os.environ["IDR_PER_BATCH_MAX_CONNECTIONS"] = "1"
679-
os.environ["IDR_ENABLE_PRIOR_AUTH"] = "1"
680674

681675

682676
@pytest.fixture(scope="module")

apps/bfd-server-ng/src/test/java/gov/cms/bfd/server/ng/IntegrationTestConfiguration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ private void runPython(PostgreSQLContainer<?> container, Instant date, String...
132132
env.put("BFD_TEST_DATE", date.toString());
133133
env.put("IDR_PER_BATCH_MIN_CONNECTIONS", "1");
134134
env.put("IDR_PER_BATCH_MAX_CONNECTIONS", "1");
135-
env.put("IDR_ENABLE_PRIOR_AUTH", "1");
136135
// Suppress noisy output unless the log level is explicitly set
137136
env.putIfAbsent("IDR_LOG_LEVEL", "WARNING");
138137

0 commit comments

Comments
 (0)