Add environment variables for macro debugging flags (#1628) #1629
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1628 by adding
DBT_MACRO_DEBUGGING
environment variable support, by default no linecache is set.While I'm in here adding debugger environment variables, I added two useful tricks I've been using locally so I don't have to keep manually patching them in:
write
, write the files to disk so the debugging experience is more pleasant. This writes a lot of files and doesn't clean them up! But boy is it helpful sometimes, just to see where you are.{{ debug() }}
will drop you into a debugger at the current line in the compiled macro. This is pretty helpful when you're debugging low-level macro weirdness and don't want to step through a million internal jinja functions just to see where you are.With
DBT_MACRO_DEBUGGING
set:With
DBT_MACRO_DEBUGGING=write
set:The extra context really shines in longer macro/function call chains when you're walking up and down the stack trying to figure out why all your
ref()
calls started returningNone
after your minor tweak to the parser or whatever.