-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
compile inline query doesn't add node #7326
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks straightforward to me 👍
def after_run(self, adapter, results): | ||
# remove inline node from manifest | ||
if self._inline_node_id: | ||
self.manifest.nodes.pop(self._inline_node_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to reset _inline_node_id as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I had it in some version then lost it due to some branch moving around.
Also added test!
["compile", "--inline", "select * from {{ ref('second_model') }}"], | ||
populate_cache=False, | ||
) | ||
assert len(manifest.nodes) == 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
@@ -40,6 +40,10 @@ def compile(self, manifest): | |||
|
|||
|
|||
class CompileTask(GraphRunnableTask): | |||
# We add a new inline node to the manifest during initialization | |||
# it should be removed before the task is complete | |||
_inline_node_id = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a bit off to have a non-constant, instance-specific representation state as a class attribute. Is there a reason this isn't defined on the instance instead via an __init__
override?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we abstract node creation/deletion into a context manager function decorator?
https://docs.python.org/3/library/contextlib.html#using-a-context-manager-as-a-function-decorator
Related to #6358
When compile a inline node, we add one additional node to the manifest. That node should be removed when compile is done.
I tried but couldn't find a way to add a test for this. was hoping to have one function to remove the line node and validate it is being called when running inline query but couldn't mock because dbt.task.compile is not a package.Didin't try hard enough last time, added test