add column_name to output of compare_column_values #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description & motivation
This small change, the addition of a
column_name
column to the output of thecompare_column_values
macro, enables a user to write a relatively simple dbt test that compares values of all columns of a given table. Here is the dbt test I wrote, which is similar to an example that I found in the README.This tests that a table called
deal_facts
with a primary keydeal_id
has the same column values in two different schemas ("prod" and whatever the target/dev schema is).The test fails if any column has rows in either table that aren't a ✅ perfect match.
The test also writes output to the logs, just like the example in the README.
This approach be extended to enable testing across multiple/all tables within a single test, but I thought starting small made sense.
If the team is interested in merging this change, I'd be happy to update my PR with some guidance in the README (although I don't think this update would break anything for current use cases).
A future enhancement could include a macro that specifically accomplishes this based on the test I've mocked up, with the addition of arguments for columns to exclude.
My opinion is that even this simple change in this PR would unlock a lot, and a macro to the same end is a "nice to have," since anyone could write a version of this test to meet their specific use case once they have
column_name
at their disposal.Apologies if I'm missing something obvious that renders this idea moot/unncessary!
Issue: #46
Checklist