Skip to content

[Feature] Support env_var usage to declare hubspot_database #130

@erenmirza

Description

@erenmirza

Is there an existing feature request for this?

  • I have searched the existing issues

Describe the Feature

Currently, the source hubspot database can be specified for the dbt hubspot packages as follows:

vars:
    hubspot_database: your_destination_name
    hubspot_schema: your_schema_name 

We have a non-production version of hubspot and a production version of hubspot which are both synced by Fivetran into separate databases.

Currently Jinja is not supported within the dbt vars config.

As a result, dynamically selecting the correct hubspot database based on environment is not easily achievable. Users would have to override dbt variables with environment variables through the CLI.

Feature: Support env_var usage to declare hubspot_database
Scenario: dbt users have nonprod and production instances of hubspot

  • Given A nonprod source and a production source exists for hubspot
    • And they are in separate databases
    • And I have not declared a static hubspot_database dbt var
  • When I run a dbt project
  • Then I should select the correct database depending on my environment

How would you implement this feature?

In src_hubspot.yml here

Replacing

sources:
  - name: hubspot
    schema: "{{ var('hubspot_schema', 'hubspot') }}"
    database: "{% if target.type != 'spark'%}{{ var('hubspot_database', target.database) }}{% endif %}"

with something that makes use of env_var. Perhaps:

sources:
  - name: hubspot
    schema: "{{ var('hubspot_schema', 'hubspot') }}"
    database: "{% if target.type != 'spark'%}{{ var('hubspot_database', env_var('HUBSPOT_DATABASE', target.database)) }}{% endif %}"

Describe alternatives you've considered

Alternative solutions include

  • Parsing environment variables and overriding dbt variables through CLI
  • Wrapping dbt variables and replacing with environment variables through scripts
  • Creating separate dbt projects for each hubspot instance to be able to dynamically select sources in downstream projects

Are you interested in contributing this feature?

  • Yes.
  • Yes, but I will need assistance.
  • No.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions