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

Add dbt profiles utilities #16889

Merged
merged 10 commits into from
Jan 31, 2025
Merged

Add dbt profiles utilities #16889

merged 10 commits into from
Jan 31, 2025

Conversation

kevingrismore
Copy link
Contributor

This module includes utilities for locating and loading dbt profiles from YAML. It also enables the resolution of block and variable references when the PrefectDbtRunner executes dbt commands by writing the resolved file to a temporary directory.

test:
  outputs:
    dev:
      type: duckdb
      path: dev.duckdb
      threads: 1

    prod:
      type: duckdb
      path: prod.duckdb
      threads: 4
      password: "{{ prefect.blocks.secret.my-password }}"

  target: "{{ prefect.variables.dbt_target }}"

At the moment, all block references resolve to calls to dbt's env_var() since blocks can contain secrets, and block values are stored as env vars. Variables are resolved directly to text.

test:
  outputs:
    dev:
      type: duckdb
      path: dev.duckdb
      threads: 1

    prod:
      type: duckdb
      path: prod.duckdb
      threads: 4
      password: "{{ env_var(PREFECT_BLOCKS_SECRET_MY_PASSWORD) }}"

  target: prod

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
  • If this pull request adds functions or classes, it includes helpful docstrings.

@kevingrismore
Copy link
Contributor Author

The block resolution function and related tests are mostly a copy of what we already do for prefect.yaml files, so let me know if there's a better way we can approach supporting this.

@kevingrismore kevingrismore marked this pull request as ready for review January 29, 2025 16:28
@kevingrismore kevingrismore added the integrations Related to integrations with other services label Jan 29, 2025
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a couple of comments/questions, but overall this LGTM!

Copy link

codspeed-hq bot commented Jan 31, 2025

CodSpeed Performance Report

Merging #16889 will not alter performance

Comparing add-dbt-profiles (052c778) with main (2e9c2ab)

Summary

✅ 2 untouched benchmarks

@kevingrismore kevingrismore merged commit 6f768a4 into main Jan 31, 2025
50 checks passed
@kevingrismore kevingrismore deleted the add-dbt-profiles branch January 31, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Related to integrations with other services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants