On dbt v2, the engine built on Fusion, a project with semantic models prints this on every command:
[warning] [SemanticModelDeprecated (dbt1157)]: The package 'shop' defines semantic models and metrics
using the legacy YAML. Please migrate to the new YAML to use the semantic layer with dbt.
“Legacy YAML” is the format with a top-level semantic_models: key, measures and type_params. The
new format puts the semantic model inside the model’s own YAML and replaces measures with simple
metrics. dbt Core 1.12 accepts both formats without a warning, so the same project may be quiet on
1.12 and noisy on v2. dbt-autofix does the migration.
Copy and paste
git add -A && git commit -m "Before Semantic Layer migration" # the tool rewrites YAML files
pip install dbt-autofix
dbt-autofix deprecations --semantic-layer --dry-run # show the changes
dbt-autofix deprecations --semantic-layer # apply them
dbt parse
mf validate-configs # or: dbt sl validate
In the Studio IDE, run the same dbt-autofix command in the command bar, then Commit and sync.
What changes
Before:
semantic_models:
- name: orders
model: ref('orders')
defaults:
agg_time_dimension: order_date
entities:
- name: order
type: primary
expr: order_id
dimensions:
- name: order_date
type: time
type_params:
time_granularity: day
- name: status
type: categorical
measures:
- name: revenue
agg: sum
expr: amount
metrics:
- name: revenue
type: simple
type_params:
measure: revenue
After:
models:
- name: orders
semantic_model:
enabled: true
agg_time_dimension: order_date
columns:
- name: order_id
entity:
type: primary
name: order
- name: order_date
dimension:
type: time
granularity: day
- name: status
dimension:
type: categorical
metrics:
- name: revenue
type: simple
agg: sum
expr: amount
The dry run lists each step: it merges the semantic model into the model, turns entities and dimensions into column properties, folds each measure into its simple metric, moves ratio and derived metrics under the model, and deletes the old top-level blocks.
Check the numbers
The migration should not change any result. Query the main metrics before and after, and compare. On the example project the monthly revenue and average order value were identical: 200 and 100 in January, 250 and 125 in February, 180 and 90 in March.
The warning that may follow
After the migration, dbt v2 may print another warning when it runs without a connection to dbt platform:
[warning] [InvalidConfig (dbt1005)]: Skipping semantic manifest validation due to: No dbt_cloud.yml
config. Set DBT_ENGINE_NO_WARN_SEMANTIC_MANIFEST_VALIDATION to suppress this warning.
It only says that the semantic checks were skipped locally. Validate with mf validate-configs, or set
up dbt_cloud.yml to validate through dbt platform.
Before you migrate
- Cross-project references. With dbt Mesh, semantic models that reference models from another project are supported only in the legacy format for now. Keep those until support arrives.
- Packages. The tool does not change installed packages in
dbt_packages/. Their maintainers have to migrate and release a new version. - Save your work. The command rewrites YAML files in place and may overwrite unsaved changes. Commit first, as above.
Reproduced with dbt v2 2.0.9 and migrated with dbt-autofix 0.22; results compared with dbt Core 1.12 and MetricFlow 0.213 on DuckDB.