-
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
Macro parsing #1057
Macro parsing #1057
Conversation
This works really well @cmcarthur! What else do we need to do to get this merged? Is it touch-up stuff, or is it missing something more fundamental? |
d5eca70
to
2451b78
Compare
I think this is all set, now that I handled the two identical filepaths in one project issue |
dbt/clients/jinja.py
Outdated
|
||
def get_node_template(self, node): | ||
# multiple nodes can be in a file, but they must have unique names! | ||
key = (node['original_file_path'], node['name']) |
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.
the key should be unique-per-file, instead of unique-per-node, no?
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.
I'm pretty confident unique-per-node is correct!
- models are a single node per file and their
raw_sql
is the full file, so it's exactly the same - macros/operations have multiple nodes per file, and
thetheir generated templates only have the named macro, and each block has a (project-unique, which is vastly more than we care about) unique nameraw_sql
is the block contents
One thing we might need to do is add in the root path/project name to the key. I hadn't considered dependent projects that happen to have an identical layout until just now. It seems that at least in some tests, original_file_path
is actually the just the path under 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.
Ok, you were totally correct. It's all about dependency packages, I misunderstood the issue because I missed the difference between do_something
and do_something2
!
899e556
to
5c6e464
Compare
I ran dbt a bunch with some sample dbt projects. For larger, realistic projects like our For smaller sample projects, the difference is small, but significant. After some non-rigorous timing, I found:
So, this represents a 25% speedup, even if it's generally less than one second. Also worth restating: this effect is less apparent if a project has even a single |
Yeah, that's about what I'd expect when to comes to the |
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.
I don't have enough insight into the jinja internals to have any input on the code here. I did however run this on a bunch of projects, and it seemed to work just fine. LGTM!
work in progress. this is promising -- it meaningfully speeds up compilation on a couple of my test projects. @drewbanin i'd love for you to give this a try on some of the slow-to-compile projects that we know of and see the impact.