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

Port cannot be set from an environment variable #2868

Closed
1 of 5 tasks
moltar opened this issue Nov 6, 2020 · 3 comments
Closed
1 of 5 tasks

Port cannot be set from an environment variable #2868

moltar opened this issue Nov 6, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@moltar
Copy link

moltar commented Nov 6, 2020

Describe the bug

Similarly to #2486, a port number cannot be provided via environment variable.

default:
  outputs:
    production:
      type: postgres
      threads: 1
      host: "{{ env_var('DBT_HOST') }}"
      port: "{{ env_var('DBT_PORT') }}"
      user: "{{ env_var('DBT_USER') }}"
      pass: "{{ env_var('DBT_PASS') }}"
      dbname: "{{ env_var('DBT_DBNAME') }}"
      schema: "{{ env_var('DBT_SCHEMA') }}"
  target: production

Results in:

Credentials in profile "default", target "production" invalid: '5432' is not of type 'integer'

Steps To Reproduce

See above config.

Expected behavior

Ability to pass port as env var.

Screenshots and log output

See above.

System information

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

Using Docker image fishtownanalytics/dbt:0.18.1.

The operating system you're using:

Using Docker image fishtownanalytics/dbt:0.18.1.

The output of python --version:

Using Docker image fishtownanalytics/dbt:0.18.1.

Additional context

See #2486

@moltar moltar added bug Something isn't working triage labels Nov 6, 2020
@jtcohen6 jtcohen6 removed the triage label Nov 8, 2020
@jtcohen6
Copy link
Contributor

jtcohen6 commented Nov 8, 2020

Hey @moltar, try adding the as_number filter, as shown in the docs:

default:
  outputs:
    production:
      type: postgres
      threads: 1
      host: "{{ env_var('DBT_HOST') }}"
      port: "{{ env_var('DBT_PORT') | as_number }}"
      user: "{{ env_var('DBT_USER') }}"
      pass: "{{ env_var('DBT_PASS') }}"
      dbname: "{{ env_var('DBT_DBNAME') }}"
      schema: "{{ env_var('DBT_SCHEMA') }}"
  target: production

This was a breaking change in dbt v0.17.1 (#2618 to be precise).

@jtcohen6 jtcohen6 closed this as completed Nov 8, 2020
@moltar
Copy link
Author

moltar commented Nov 9, 2020

I can confirm that your suggestion does work.

I've tried a variation of that, where I casted it to number, but omitted the quotes, thinking that the quotes would negate the number casting.

Thanks!

@eguidos
Copy link

eguidos commented May 9, 2023

This suggestion worked perfectly fine.

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

3 participants