Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

handle all custom schemas scenarios #498

Merged
merged 5 commits into from
Apr 14, 2023
Merged

Conversation

dlawin
Copy link
Contributor

@dlawin dlawin commented Apr 14, 2023

To (hopefully) cover all custom schemas scenarios I've reworked some of the data_diff variables in dbt_project.yml

vars:
  data_diff:
    prod_database: analytics-383622
    prod_schema: prod # default
    prod_custom_schema: prod_<custom_schema> # falls back to default when there is no custom schema
  • Removed custom_schemas boolean
  • Added prod_custom_schema
    • When a model has a custom schema, the <custom_schema> will be replaced with the custom schema name
    • Using the example above
      • config(schema = 'marketing') -> analytics-383622.prod_marketing.model
      • No custom schema -> analytics-383622.prod.model

Additional examples:

vars:
 data_diff:
   prod_database: analytics-383622
   prod_schema: prod # default
   prod_custom_schema: <custom_schema> # falls back to default when there is no custom schema
  • config(schema = 'marketing') -> analytics-383622.marketing.model
  • No custom schema -> analytics-383622.prod.model
vars:
  data_diff:
    prod_database: analytics-383622
    prod_schema: prod # default
  • config(schema = 'marketing') -> Error:
    Screenshot 2023-04-13 at 6 24 00 PM
  • No custom schema -> analytics-383622.prod.model
vars:
  data_diff:
    prod_database: analytics-383622
  • schema always matches dev
    • analytics.marketing.model <> dev_dan.marketing.model

Resolves #447
Resolves partially #454

@dlawin dlawin added bug Something isn't working enhancement New feature or request --dbt Issues/features related to the dbt integration labels Apr 14, 2023
@dlawin dlawin self-assigned this Apr 14, 2023
@kylemcnair
Copy link
Contributor

Outside the scope of this PR, but do you see a similar approach working for custom DBs? @dlawin

@dlawin dlawin marked this pull request as ready for review April 14, 2023 16:06
@dlawin
Copy link
Contributor Author

dlawin commented Apr 14, 2023

Outside the scope of this PR, but do you see a similar approach working for custom DBs? @dlawin

yeah I think the same sort of pattern replacement would work there, I'm not very familiar with how folks typically use custom databases though

@dlawin
Copy link
Contributor Author

dlawin commented Apr 14, 2023

Outside the scope of this PR, but do you see a similar approach working for custom DBs? @dlawin

yeah I think the same sort of pattern replacement would work there, I'm not very familiar with how folks typically use custom databases though

Something like:

vars:
 data_diff:
   prod_database: analytics-383622 #default
   prod_custom_database: <custom_database> # used when there is a config(database='blah')
   prod_schema: prod # default
   prod_custom_schema: <custom_schema> # falls back to default when there is no custom schema

@CoreyGaunt
Copy link

This is a great refactor! Thanks for digging in on this @dlawin!

@dlawin dlawin merged commit 5632150 into datafold:master Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
--dbt Issues/features related to the dbt integration bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Advanced custom schemas (dynamic schema behavior based on target)
4 participants