test(data): silver business-rule data tests — non-negative counts (#1321)#1350
Conversation
…unts (constructorfabric#1321) First custom singular data test for the silver layer: activity counts on class_collab_document_activity can never be negative (a negative value means a broken transform / bad source row that would corrupt any summed metric). dbt fails the build if it returns rows; honest NULLs are not flagged. Pattern for the silver-integrity rollout under constructorfabric#1321/constructorfabric#1323 (extend to the other class_* metric tables). Enforced data_type contracts are intentionally NOT added here yet — the union models' exact types (e.g. MD5()->FixedString(16) vs String) can't be proven without a dbt run, so they land once the warehouse-gated CI is wired (the prerequisite step). Signed-off-by: Kenan Salim <kenan.salim@rolos.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new dbt singular test SQL file ChangesNon-negative collab document counts data-quality test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…unts (constructorfabric#1321) Aligns the silver business-rule test with the documented data-quality convention (tests/README.md / ADR 0005) instead of a bare build-blocking singular test: - add config(tags=['data_quality'], severity='warn', store_failures=true, meta{...}) so the check joins the monitored catalog, keeps failing rows in an audit table for drill-down, and emits a finding — rather than hard-failing dbt build with no stored rows. Mirrors the existing physical_bound check assert_meeting_duration_caps. - read class_collab_document_activity FINAL (RMT) per the README, so transient duplicates can't surface as repeated violations. - move under tests/collaboration/ to match the domain layout. Not changed: no dbt_utils/dbt-expectations (the project intentionally ships no packages.yml — singular SQL is the standard); no magic-number upper bound (statistical anomaly detection is a separate scheduled check); no shared<=viewed cross-column rule (the Graph activity counts are independent, so that invariant is unverified and would false-fire). Signed-off-by: Kenan Salim <kenan.salim@rolos.com>
|
Two things changed in the last commit, and the reasoning behind each: 1. Wrapped the test in a
This also matches the repo's documented data-quality convention ( 2. Read the table
|
…ctorfabric#1321) Address PR review: include `date` in the stored-failure SELECT so on-call gets the activity day of the offending count directly in the audit rows, without a second lookup. Kept as context only — not a filter: a negative count is corruption on any partition, so the integrity check stays unbounded over the full table (no date window). Signed-off-by: Kenan Salim <kenan.salim@gmail.com>
Review feedback — dispositionThanks for the thorough review. Triaged the three points; one applied, two intentionally not: 1. Add 2. Window 3. "Silent drop" upstream blindspot — ✅ acknowledged, out of scope for this file |
What
First custom singular data test for the silver layer (the feedback's section 4):
assert_collab_document_counts_non_negative.sql— activity counts onclass_collab_document_activitycan never be < 0. dbt fails the build if any row violates it; honest NULLs (NULL < 0→ NULL) are not flagged.Why
A negative count = a broken transform or bad source row, and it silently corrupts any metric that sums it. This is the verifiable, no-warehouse-needed slice of the silver-integrity work under EPIC #1321 / #1323.
Scope / next
accepted_valuestests across the otherclass_*tables.contract: {enforced: true}withdata_type— the union models' exact ClickHouse types can't be validated without adbt build, so they land oncedata-checks.ymlruns against a populated ClickHouse. Authoring them blind would risk a red build on a wrong type.Draft until the dbt CI run validates it (dbt isn't runnable in this environment).
Summary by CodeRabbit