Dynamic Schemas
Requesting for beta
We are kicking off a beta and would love for you to be involved! Sign up here if you want to join in.
Introduction
The Dynamic Schema feature also supports all the use cases mentioned in Dynamic Data Sources.
Unlike those who differentiate their data by data sources, some users prefer to organize data by schema
(or in BigQuery, they call it dataset
) within a single source. For these users, the Dynamic Schemas feature has got you covered.
How to use
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 (in the use case where you separate your dev/prod by schema):
// 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 ;;
}