Makes the blog-generated product run on the digital-core domain built from
semprini-data-domain, with the same changes the canonical template received:
- flink/job.sql connects to ods:5432/ods as postgres with ${ODS_PASSWORD},
substituted by data-domain at submission, instead of the blog's credentials
- lakehouse/010_replication.sql uses the platform's `ods` sync group and grants
the lake tables to ducklake_reader and ducklake_writer
- product.yaml sync group, odps.yaml access URLs (domain ports 20000-20003,
management zone Apicurio on 8081), CLI names in comments
Adds tests/: the canonical template's generic unit tests and this product's
expectations.yaml (seed rows, 24 constraint rejections, 5 relationship
traversals, one inbound-to-tombstone round trip).
Verified on digital-core on 2026-09-18: 65 of 65 smoke checks, 100 unit tests
passing, and registered in OpenMetadata under the digital-core domain.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
34 lines
1.6 KiB
Python
34 lines
1.6 KiB
Python
"""Analytic SQL: pg_duckpipe has replicated every seed row into the lake, and Trino serves it."""
|
|
|
|
import pytest
|
|
|
|
from semprini_data_domain.testing import expectations_for, same_value
|
|
|
|
TABLES = list(expectations_for(__file__)["tables"].items())
|
|
SAMPLES = [(table, sample) for table, spec in TABLES for sample in spec.get("samples", [])]
|
|
|
|
|
|
def key_of(dp, table):
|
|
return next(t.key for t in dp.product.tables if t.name == table)
|
|
|
|
|
|
@pytest.mark.parametrize("table,spec", TABLES, ids=[t for t, _ in TABLES])
|
|
def test_lake_matches_ods(dp, table, spec):
|
|
lake = f"{dp.product.trino_catalog}.{dp.product.lake_schema}.{table}"
|
|
ods = dp.sql(f"SELECT count(*) AS n FROM {dp.product.schema}.{table}")[0]["n"]
|
|
assert ods == spec["rows"]
|
|
dp.eventually(lambda: dp.trino(f"SELECT count(*) AS n FROM {lake}") == [{"n": ods}])
|
|
|
|
|
|
@pytest.mark.parametrize("table,sample", SAMPLES, ids=[t for t, _ in SAMPLES])
|
|
def test_seed_row_in_lake(dp, table, sample):
|
|
key = key_of(dp, table)
|
|
lake = f"{dp.product.trino_catalog}.{dp.product.lake_schema}.{table}"
|
|
# Every column is cast to varchar so dates and uuids compare as text, the way the seed writes them.
|
|
columns = ", ".join(f"CAST({column} AS varchar) AS {column}" for column in sample)
|
|
rows = dp.trino(f"SELECT {columns} FROM {lake} WHERE CAST({key} AS varchar) = '{sample[key]}'")
|
|
assert len(rows) == 1, f"{sample[key]} not in {lake}"
|
|
for column, expected in sample.items():
|
|
want = None if expected is None else (str(expected).lower() if isinstance(expected, bool) else expected)
|
|
assert same_value(want, rows[0][column]), f"{column}: {rows[0][column]!r} != {expected!r}"
|