AltimateAI / AltimateAI/vscode-dbt-power-user

Wrong schema used for 'sync with the database' in documentation editor

Open
#884 5 comments 1 reaction 1 assignee Claimed by @mdesmet View on GitHub
bug
Dominant language
JavaScript
Stars
585
Forks
121
Avg merge
5d 39m
Merged PRs (30d)
4

Description

### Expected behavior

When using 'sync with database' in the documentation editor, I expect it to use the same schema as it would be used during a dbt run executed by the extension.

### Actual behavior

Another schema is used, and since the table is not present there, no retrieval of metadata happens.

### Steps To Reproduce

In our profiles.yml, the schema is defined as an env variable:
`schema: "{{ env_var('DBT_DATASET_PREFIX') }}"`
We change this variable dynamically depending on which git branch is currently checked out in our project.
For the extension to work we added a custom dbt wrapper which does the following:
* Check active git branch in the project folder
* Set environment variable accordingly
* Call dbt command

With this setup dbt-power-user works well with the dynamic schema names, i.e. I can call the run button for a model and it will be deployed in the correct schema depending on the current git branch.

For the sync with DB in the documentation editor this does not work.
We observed that it always tries to sync using the 'default' schema, i.e. the one as if the environment variable was not changed from its default value.
One way how I could imagine this to happen is, if the profile.yml is read once when the extension is initialized, and no updates of env_vars are considered. However since it works for other functions of the extension (like e.g. dbt run) I doubt that thats the case here.

### Log output/Screenshots

_No response_

### Operating System

Debian 11

### dbt version

1.7.3

### dbt Adapter

bigquery

### dbt Power User version

0.31.3

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.