Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding test materialization, implement for data tests #3181

Merged
merged 3 commits into from
Mar 30, 2021

Conversation

kwigley
Copy link
Contributor

@kwigley kwigley commented Mar 19, 2021

resolves #3154

Description

This PR pulls data test logic out of a CTE injected during compilation and puts it in a new test materialization. This mimics existing data test logic (simple checking of count(*)), subsequent changes will add more functionality.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot cla-bot bot added the cla:yes label Mar 19, 2021
@kwigley kwigley self-assigned this Mar 19, 2021
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you're still finalizing the last few pieces, but I couldn't help myself, so I took this for a spin. Everything worked the way I'd hoped! I was able to override the test materialization locally, with both default and adapter-specific implementations, and dbt preferred my own each time.

@@ -0,0 +1,10 @@
{%- materialization test, default -%}
Copy link
Contributor

@jtcohen6 jtcohen6 Mar 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that the file name is materializations/test/data.sql, and I think this is rightly just materializations/test.sql. We'll want to use one & the same materialization for both data one-off and schema generic/reusable tests. (I know that's one of the next issues to come.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, please help yourself! Thanks for taking it for a spin. I'll update the name accordingly :)

@kwigley kwigley force-pushed the feature/data-test-materialization branch 2 times, most recently from bfe080e to 3b8c814 Compare March 23, 2021 20:38
@kwigley kwigley requested review from gshank, a team and nathaniel-may and removed request for a team March 23, 2021 20:41
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good in my book!

f"Returned {num_rows} rows and {num_cols} cols, but expected "
f"1 row and 1 column"
)
return int(table[0][0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than just returning a single number to the execute method, I imagine the materialization-calling method should construct and return the full RunResult, similar to _build_run_model_result. It seems like that will enable us to manage the dynamic message interpolation, as well as recording the adapter_response.

Of course, those can and should be new issues! It's cool to see the path taking shape.

Copy link
Contributor

@nathaniel-may nathaniel-may left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kwigley kwigley force-pushed the feature/data-test-materialization branch from f2cb813 to 5841713 Compare March 29, 2021 13:26
@kwigley kwigley force-pushed the feature/data-test-materialization branch from 5841713 to 12e281f Compare March 29, 2021 13:50
.format(context)
)

MacroGenerator(materialization_macro, context)()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document what this line with MacroGenerator does. If you don't already know it might be confusing.

@kwigley kwigley merged commit 17e57f1 into develop Mar 30, 2021
@kwigley kwigley deleted the feature/data-test-materialization branch March 30, 2021 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move data test "rendering" out of python compilation step
4 participants