Menu ▾ ▴

#74 fix(tests): make 3 allocation/consolidation tests compile on ClickHouse

closed
nobody
None
2026-06-21
2026-06-19
Anonymous
No

Originally created by: grynn-in

Fixes [#70].

Three data-tests errored at run time (ClickHouse exceptions) rather than validating anything:

Test Was Fix
assert_reciprocal_converges refs non-existent final_iteration (code 47) use step_order, the iteration column on gold_allocation_results
assert_tier_total_equals_pool having sum(...) > max(...) read as nested aggregate (code 184) aggregate in a subquery, compare plain cols in outer WHERE
assert_ownership_uses_effective_date date-range BETWEEN across both tables in JOIN ... ON (code 403) keep ON on equi-keys, move the range to WHERE (equivalent for INNER JOIN)

Verification

dbt test --select assert_reciprocal_converges assert_tier_total_equals_pool assert_ownership_uses_effective_date
# Done. PASS=3 WARN=0 ERROR=0

Out of scope

tests/assert_dynamic_step_count.sql also fails, but as a genuine data assertion (Got 1 result, configured to fail if != 0), not a compile error — left for a separate look.

Related

Tickets: #70

Discussion

  • Anonymous

    Anonymous - 2026-06-19

    Originally posted by: grynn-in

    Independent review — REQUEST-CHANGES (1 of 3)

    #2 (assert_tier_total_equals_pool) and [#3] (assert_ownership_uses_effective_date): correct. The HAVING→subquery+WHERE rewrite is semantically identical (same group keys, same aggregate comparison), and moving the date-range BETWEEN from ON to WHERE is equivalent for an INNER JOIN (equi-keys stay in ON).

    #1 (assert_reciprocal_converges): final_iteration → step_order is semantically wrong. step_order is the multistep cascade ordering (allocation_engine_multistep), not the reciprocal solver's iteration counter — that's final_iteration, produced by allocation_engine_reciprocal(), which no model invokes. gold_allocation_results is built only by the multistep engine (step_down), so it has no reciprocal data and no iteration column. The swap makes the test compile and always pass — a false-green convergence guard, not a fix.

    Action: I'll disable this test with {{ config(enabled=false) }} and a comment explaining it can't be evaluated until reciprocal output is materialized (keeping final_iteration as the intended column for when it is), rather than rewrite it to always-pass. Updating the PR.

     

    Related

    Tickets: #3

  • Anonymous

    Anonymous - 2026-06-19

    Ticket changed by: grynn-in

    • status: open --> closed
     

Log in to post a comment.