-
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
add macros to flat graph #332
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.
this is great so far! keen to see how you avoid compiling only the relevant macros for each model
dbt/compilation.py
Outdated
name = macro.get('name') | ||
package_name = macro.get('package_name') | ||
|
||
if context.get(package_name, {}).get(name) is not 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.
how would this happen?
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.
we parse each macro once, but parsing a "macro" is really parsing the file that macro is in. so, without this code, if a file contained 3 macros, we'd parse that file 3 times.
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.
got it
@@ -425,16 +439,7 @@ def compile_nodes(self, linker, nodes, macro_generator): | |||
if cycle: | |||
raise RuntimeError("Found a cycle: {}".format(cycle)) | |||
|
|||
return wrapped_nodes, written_nodes | |||
|
|||
def generate_macros(self, all_macros): |
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.
👍 👍 👍
dbt/compilation.py
Outdated
|
||
compiled_nodes, written_nodes = self.compile_nodes(linker, all_nodes, | ||
macro_generator) | ||
compiled_graph, written_nodes = self.compile_graph(linker, flat_graph) | ||
|
||
self.write_graph_file(linker) | ||
|
||
stats = {} |
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.
we can use a defaultdict here :)
stats = defaultdict(int)
stats[node.get('resource_type')] += 1
... just sayin
dbt/parser.py
Outdated
return to_return | ||
|
||
|
||
class FakeProject: |
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.
what's going on here?
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.
lgtm
@@ -30,6 +29,45 @@ | |||
graph_file_name = 'graph.gpickle' | |||
|
|||
|
|||
def recursively_parse_macros_for_node(node, flat_graph, context): | |||
# this once worked, but is now long dead |
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.
hah
automatic commit by git-black, original commits: de06d65
No description provided.