Within my Dataform project, I've configured tables with incremental mode.
My objective is to use schema suffixes to isolate each development into distinct schemas (datasets). However, when I apply a schema suffix, I encounter an error with the incremental table, as there is no table named "schema_[schema_suffix].table_name."
This is expected as the dataset hasn't been generated.
My question is: Should I create the dataset manually every time?
Solved! Go to Solution.
When using schema suffixes in Google Cloud Dataform to isolate development environments, you may encounter issues with missing datasets, especially when dealing with incremental tables. Dataform does not automatically create datasets with schema suffixes, so here are two recommended approaches:
1. Manual Dataset Creation:
schema_suffix
combinations.2. Automated Dataset Creation through Javascript:
const isProduction = dataform.projectConfig.defaultSchema.endsWith('_prod');
let targetSchema = dataform.targetSchema;
if (isProduction) {
targetSchema += "_prod";
}
// Replace 'datasetExists' and 'createDataset' with actual Dataform API methods
if (!dataform.backend.datasetExists(targetSchema)) {
console.log(`Creating dataset: ${targetSchema}`);
dataform.backend.createDataset(targetSchema);
}
datasetExists
and createDataset
methods align with the current Dataform API. Adapt this script to your specific needs and API versions.Recommendations:
By choosing the appropriate approach, you can effectively manage development environments with schema suffixes and ensure smooth handling of incremental tables without missing datasets.
When using schema suffixes in Google Cloud Dataform to isolate development environments, you may encounter issues with missing datasets, especially when dealing with incremental tables. Dataform does not automatically create datasets with schema suffixes, so here are two recommended approaches:
1. Manual Dataset Creation:
schema_suffix
combinations.2. Automated Dataset Creation through Javascript:
const isProduction = dataform.projectConfig.defaultSchema.endsWith('_prod');
let targetSchema = dataform.targetSchema;
if (isProduction) {
targetSchema += "_prod";
}
// Replace 'datasetExists' and 'createDataset' with actual Dataform API methods
if (!dataform.backend.datasetExists(targetSchema)) {
console.log(`Creating dataset: ${targetSchema}`);
dataform.backend.createDataset(targetSchema);
}
datasetExists
and createDataset
methods align with the current Dataform API. Adapt this script to your specific needs and API versions.Recommendations:
By choosing the appropriate approach, you can effectively manage development environments with schema suffixes and ensure smooth handling of incremental tables without missing datasets.