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

generate_schema_name should use the root-project macro definition #801

Closed
drewbanin opened this issue Jun 19, 2018 · 1 comment
Closed
Assignees
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors!
Milestone

Comments

@drewbanin
Copy link
Contributor

drewbanin commented Jun 19, 2018

Right now, it uses the macro defined in the package itself (usually undefined). That's undesirable, as schemas for models inside of packages can't be configured without duplicating the macro logic inside of the package. See here

Testing

models/local_model.sql

select 1 as id

dbt_modules/package_name/models/package_model.sql

select 1 as id

macros/generate_schema_name.sql

{% macro generate_schema_name(custom_schema_name=none) -%}
  overriden_schema_name
{%- endmacro %}

^ Given the above models and macros, a dbt run should produce the following views:

  • overriden_schema_name.local_model
  • overriden_schema_name.package_model

Currently in dbt, the package_model will be built into the schema specified in the active profile.

@drewbanin drewbanin added bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors! estimate: 1 labels Jun 19, 2018
@drewbanin
Copy link
Contributor Author

We can fix this by updating the parsing code to use the context from the root project, rather than the package that the node is sourced from. That code is here: https://github.com/fishtown-analytics/dbt/blob/dev/guion-bluford/dbt/parser/base.py#L126

@jthandy jthandy added this to the Stephen Girard milestone Oct 25, 2018
@drewbanin drewbanin modified the milestones: Stephen Girard, Grace Kelly Nov 2, 2018
@beckjake beckjake self-assigned this Dec 3, 2018
beckjake added a commit that referenced this issue Dec 5, 2018
…e-schema-name

get the default schema name generator from the root package [#801]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors!
Projects
None yet
Development

No branches or pull requests

3 participants