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

fix analysis to only compile sql once like model nodes [#1152] #1164

Merged
merged 1 commit into from
Dec 3, 2018

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented Dec 3, 2018

Fixes #1152
Due to dbt's parsing structure, the existing analysis code compiles its contents twice, which is why raw blocks aren't accepted. I've changed the compiler to treat Analysis nodes more like Models during compilation, instead of like seeds and tests. Based on what I found, custom tests probably don't respect raw blocks in their jinja and that's probably harder to fix.

It's possible that I don't understand analysis nodes very well and so my fix is just totally wrong... there isn't much of an existing test suite around them.

This fix may also break existing code since it only renders the output once instead of twice, and people may have written analyses with this behavior in mind.

@beckjake beckjake requested a review from cmcarthur December 3, 2018 20:12
@@ -132,7 +132,7 @@ def compile_node(self, node, manifest, extra_context=None):

injected_node, _ = prepend_ctes(compiled_node, manifest)

should_wrap = {NodeType.Test, NodeType.Analysis, NodeType.Operation}
should_wrap = {NodeType.Test, NodeType.Operation}
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm unsure why Analysis nodes were ever in here. We definitely do not wrap them. This whole function is... not good. Would be great to revisit at some point soon

Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

I tested this out locally and it works great. I think we can probably destroy the whole concept of wrapped_sql. That's from a time before materializations!

Looks like that will be a challenge for tests, so i think this PR is a-ok for now

@beckjake beckjake merged commit aa9d43a into dev/grace-kelly Dec 3, 2018
@beckjake beckjake deleted the fix/analysis-parsing-inside-raw branch December 3, 2018 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants