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

Missing vars in generate_schema_name macro do not fail the run #2473

Closed
beckjake opened this issue May 20, 2020 · 1 comment
Closed

Missing vars in generate_schema_name macro do not fail the run #2473

beckjake opened this issue May 20, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@beckjake
Copy link
Contributor

Describe the bug

When there is a var('foo') call in a generate_schema_name macro, if foo does not exist, dbt returns None for it.

Steps To Reproduce

  1. Add this macro:
{% macro generate_schema_name(custom_schema_name, node) -%}
    {% do log(' *** The var is: ' ~ var('myvar'), info=true) %}
    {% do return(target.schema) %}
{%- endmacro %}
  1. Do not declare myvar
  2. Run dbt
  3. get a bunch of log messages that The var is: None.

Expected behavior

dbt should fail with an error about the var not being set.

System information

Any database, any python, any OS.

The output of dbt --version:

0.17.0rc1

Additional context

This is caused by dbt using the parse context for the generate_*_name macros. Really, we want a special context that is mostly the parse context except with runtime behavior for var.

This fix should be fairly straightforward as the context is only used for these macros, we can just change the macros we call.

@beckjake beckjake added the bug Something isn't working label May 20, 2020
@beckjake beckjake self-assigned this May 20, 2020
@drewbanin
Copy link
Contributor

closed by #2477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants