[CT-707] Expose check_relations_equal + consolidate with dbt-utils generic tests #5318
Description
To assert that two relations are identical, we have similar logic expressed in a few places today:
- Custom generic tests in
dbt-utils
: theequality
,cardinality_equality
, and (to a lesser extent)equal_rowcount
COLUMNS_EQUAL_SQL
+get_rows_different_sql
, which are used extensively (but exclusively) in our functional testing framework today:
dbt-core/core/dbt/adapters/base/impl.py
Lines 1093 to 1149 in 3996a69
Straightforward change
Could we consolidate the logic in both those places, so that we're not duplicating the same SQL (and requiring adapter maintainers to do the same)?
Related improvements
Some good feedback on the latter, in #4455 (reply in thread) — trying to answer the question, "Could/should the functional testing framework also enable unit testing models/macros for end users?" — that the output of check_relations_equal
assertion statements could be more useful:
When a test does fail we get this message:
AssertionError: Got 1 different rows between DEV_CEREBRO.test16539256090777326094_test_complex_model.actual and DEV_CEREBRO.test16539256090777326094_test_complex_model.expected
which isn't informative enough to workout what's different between the expected and actual