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

num_retries doesn't work with env_var #110

Closed
hagai-arad opened this issue Jan 10, 2023 · 4 comments
Closed

num_retries doesn't work with env_var #110

hagai-arad opened this issue Jan 10, 2023 · 4 comments

Comments

@hagai-arad
Copy link

Hi,

I'm using env_var in my profile.yml file, but when trying to set the num_retires attribute with env_var it fails with the following error:

ERROR: Runtime Error
  Credentials in profile "my_profile", target "dev" invalid: '0' is not valid under any of the given schemas

To set the env var I ran this: export DBT_ATHENA_NUM_RETRIES=0

My profile.yml:

my_profile:
  outputs:
    dev:
      database: "{{ env_var('DBT_ATHENA_DB') }}"
      region_name: "{{ env_var('DBT_REGION_NAME') }}"
      s3_staging_dir: "{{ env_var('DBT_S3_STAGING_DIR') }}"
      schema: "{{ env_var('DBT_ATHENA_SCHEMA') }}"
      type: athena
      num_retries: "{{ env_var('DBT_ATHENA_NUM_RETRIES') }}"
  target: dev

A few notes:

  • When using the 0 directly it works fine: num_retries: 0
  • The other attributes are assigned as expected using the env_var
@nicor88
Copy link
Member

nicor88 commented Jan 10, 2023

The issue is on how you use the "{{ env_var('DBT_ATHENA_NUM_RETRIES') }}" as it's rendered as a string, could you try
{{ env_var('DBT_ATHENA_NUM_RETRIES') }} without quotes?

@hagai-arad
Copy link
Author

Already tried, it throws a syntax error.

I also tried:
export DBT_ATHENA_NUM_RETRIES='0'
and
export DBT_ATHENA_NUM_RETRIES="0"

@nicor88
Copy link
Member

nicor88 commented Jan 10, 2023

The issue seems to be on your side, you are passing a string to a value that should be an integer. Try this
"{{env_var('DBT_ATHENA_NUM_RETRIES') | int }}"

If you look at this docs https://docs.getdbt.com/reference/dbt-jinja-functions/env_var it give you the int on how to cast string as int :)

@hagai-arad
Copy link
Author

You are right :)
Thanks!

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

No branches or pull requests

2 participants