-
Notifications
You must be signed in to change notification settings - Fork 180
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
[ADAP-386] [Bug] prerelease macro snowflake_warehouse
unexpected behaviour
#533
Comments
snowflake_warehouse
unexpected behavioursnowflake_warehouse
unexpected behaviour
Hey @manugarri, I was not able to reproduce the issue. Core:
- installed: 1.5.0-b4
- latest: 1.4.5 - Ahead of latest version!
Plugins:
- snowflake: 1.5.0b3 - Ahead of latest version! I added the following environment variable: export adap_386=prod I added the following macro: {% macro snowflake_warehouse(warehouse) -%}
{% set foo = env_var('adap_386') %}
{{ return(foo) }}
{%- endmacro %} Ran the following model: {{ config(materialized='table') }}
{% set w = snowflake_warehouse() %}
with source_data as (
select 1 as id, '{{w}}' as wh
union all
select null as id, '{{w}}' as wh
)
select *
from source_data And got |
hey @Fleid thanks for reaching out!, I will try your example, would you mind sharing your example dbt_project so i can replicate? |
I'm using what you get from |
@manugarri was hoping on to test his as well and was seeing same thing as you while working in cli. I had missed this step |
@Fleid thanks, i tried to replicate by running dbt init with minimal modifications given my company snowflake policies (we dont use public schema). so i run add the macro in
set up the dbt project settings like this
Run Now replacing the macro with
Fails with the error i mentioned. here is a screenshot of the logs |
Another issue that might just be a feature request is, shouldnt the default macro |
@manugarri working toward replicating with your example; out of curiosity what would you expect
|
@McKnight-42 my original intentions where to setup a macro that select different warehouses depending on whether an analyst is testing dbt locally versus running automated runs on airflow. We use environment variables on our profiles.yml
My original implementation for the macro was something like this:
this was failing with the error i mentioned. In the end some very helpful person at the dbt slack helped me and suggested replacing But still, it sounds like allowing environment variables in this macro like any other macro would be useful for other use cases. Another use case that just arose at my company, we want to have different warehouses per environment, but we want a single profiles.yml (since the prod dbt runs on docker ECS but local runs for multiple analysts) if we have an environment variable to define the environment dbt is running, we can include that environment variable in the mapping function i shared above |
@manugarri after some more digging we have decided for now to actually revert #503 we now think that this method is the wrong way as it allows for some unintended consequences and will be trying to find a better way forward. sorry for any inconvenience this causes |
As @McKnight-42 mentioned, we are reverting the change, so I'm closing this issue. |
@McKnight-42 no problem, better to find an improved solution in a future release. In the meantime, what do you think would be the best way of tackling the issue of dynamic warehouses? @Fleid will do that |
Is this a new bug in dbt-snowflake?
Current Behavior
On current prerelease (v1.5.0b3) a default macro
snowflake_warehouse
has been added (here is the PR).I am testing a way to use environment variables to dynamically decide which warehouse to allocate based on the user.
But adding an
env_var
lookup to the macro throws exceptions.For example, this macro definition throws the exception when doing
dbt run
:'MacroManifest' object has no attribute 'env_vars'
while this one doesnt
Expected Behavior
environment variables should be accesible in the
snowflake_warehouse
macro as usual.Steps To Reproduce
snowflake_warehouse
to a project with this definition:dbt run
Relevant log output
No response
Environment
Additional Context
No response
The text was updated successfully, but these errors were encountered: