Generate Models
How to use the generate command to create semantic models from dbt catalogs
Overview of the buster generate
Command
The buster generate
command automatically creates semantic models from your dbt catalog. This significantly reduces the time and effort required to set up your semantic layer, especially for projects with many tables.
Basic Usage
To generate semantic models from your dbt catalog:
Where:
[path]
is an optional path to your dbt catalog file--output-dir DIR
specifies where to save the generated models
How It Works
The generate
command:
- Locates your dbt catalog.json file (either at the specified path or in the default location)
- Parses the catalog to extract table schemas and column metadata
- Intelligently determines whether each column should be a dimension or measure based on its data type
- Creates YAML semantic model files following Buster’s best practices
- Places these files either alongside your SQL files or in a specified output directory
Type Classification
The command uses these rules to classify your columns:
- Dimensions are created for:
- String/text types
- Date/time types (timestamp, date, time)
- Boolean types
- UUID types
- Enum types
- Measures are created for:
- Numeric types (integer, decimal, float)
- Money types
Additionally, the command applies sensible defaults for:
- Identifying primary keys
- Setting appropriate aggregation types
- Adding searchable flags to common searchable fields
Command Options
The following options are available:
--output-dir DIR
: Save generated models to a specific directory--force
: Overwrite existing models, even if they were manually modified--dry-run
: Show what would be generated without writing files--verbose
: Show detailed information about the generation process
Examples
Basic Generation
Generate models from the default dbt catalog location:
Specify Catalog Path
Generate models from a specific dbt catalog file:
Custom Output Directory
Save generated models to a specific directory:
Handling Existing Models
When generating models for an existing project:
- New Models: Created with sensible defaults
- Existing Models: Updated while preserving your manual edits
- New columns will be added as dimensions or measures
- Existing dimension/measure definitions will be preserved
- Custom metrics, filters, and relationships won’t be affected
This means you can safely regenerate models as your schema evolves without losing your customizations.
Output Example
A generated model file will look like this:
Integration with buster init
When initializing a new project with buster init
, you have the option to automatically generate semantic models from your dbt catalog as part of the setup process. This provides a seamless workflow from project initialization to having a functional semantic layer.
Best Practices
- Initial Generation: Use
buster generate
when first setting up your semantic layer to quickly scaffold models. - Enrich Generated Models: After generation, enhance the models with:
- More detailed descriptions
- Custom metrics
- Useful filters
- Proper relationships between models
- Regenerate When Schemas Change: Update your semantic models when new columns are added to your dbt models.
Next Steps
After generating your semantic models:
- Review and enhance the generated models
- Define relationships between models
- Add metrics and filters
- Deploy your project
Related Commands
buster init
- Initialize a new Buster projectbuster deploy
- Deploy your project to the Buster platform- Integrating with dbt - Learn more about Buster’s integration with dbt