To follow up on the Dynamic Data Sources feature, this is another cool feature that might be useful, dynamic schemas
📊 Dynamic Schema for Dev/Prod Environments
For those of you who separate dev and prod environments based on schema (or datasets in BigQuery) instead of the actual data source, we’ve got you covered with our Dynamic Schema option.
This feature lets you switch schemas easily using basic string interpolation in your model's table_name
property.
Here’s a quick example to show how it works:
// This is for dynamic schema use case by branch
const current_branch = H.git.current_branch
const dynamic_schema =
if (current_branch == 'master') { 'prod' }
else if (current_branch == 'staging') { 'stg' }
else { 'dev' }
// in Table Model
model users {
type: 'table'
data_source_name: 'your_db'
// dynamic schema in table name
table_name: '${dynamic_schema}.users'
}
// in Query Model
model derived_users {
type: 'query'
data_source_name: 'your_db'
// dynamic schema in a query
query: @sql select * from ${dynamic_schema}.users ;;
}
🛠️ What does this mean?
You can automatically point to the correct schema based on the branch you’re working on—making your workflow even smoother!
info
And don’t forget, if you find this useful, be sure to submit your beta request! We’ll let you know as soon as it’s ready to be used