-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Feature] unit testing: dbt should tell me why it couldn't get columns (the model doesn't yet exist) #10014
Comments
That's awesome 🤩 Yeah, it would be nice to give more hints to our intrepid hikers on how to get back on the trail. Re-labeling as a feature request and adding the |
Hello! A few thoughts:
I agree this is a bit vague. You could not be able to get the columns from this relation because:
I'm ok with updating it to:
|
Hey @graciegoheen @joellabes, I would like to take this issue to get started in the repository, can I take it ? |
@AlejandroBlanco2001 That would be great! |
I've traced the error down to the Jinja parser, snugly nested in rendered = None
try:
rendered = render_template(template, ctx, node)
except Exception as e:
raise CustomException() My idea is to use the already existing class class ModelNotExist(CompilationError):
def __init__(self, operation_name) -> None:
super().__init__(msg=self.get_message())
def get_message(self) -> str:
msg = (
f"some message"
)
return msg If we have another mechanism to handle exceptions, I'm open to hear other approach. I reckon the proposed message fits ok for this scenario.
Thoughts @graciegoheen @dbeatty10? |
@AlejandroBlanco2001 Nice detective work! I think this might be a bit simpler though — the compilation error is actually being raised directly by the |
@jtcohen6 Oh, thanks for being even more specific about where the message is. I think that I wil update the message with the suggestion of @graciegoheen |
@jtcohen6 @graciegoheen PR opened 🎉 |
Is this a new bug in dbt-core?
Current Behavior
I tried making my first unit test from scratch (no using the docs!) and got the below error.
It turns out that the issue was that the models hadn't been built yet, but the error didn't explain why it couldn’t get the columns.
Expected Behavior
Ignoring the fact that there could be other causes for this (ephemeral models? permissions issues? idk), the general thing that I felt was missing was an explanation of what I could do to solve it. Something like
Not able to get columns for unit test 'unit_test_model_a' from relation ANALYTICS_DEV.DBT_JLABES_INT_TESTS.unit_test_model_a because the relation doesn't exist.
would be plenty to make me go "oh of course I need to do a build (or defer to prod).
Steps To Reproduce
dbt test -s test_type:unit
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: