[Bug] dbt 1.12: inline semantic model on a versioned model (columns under versions[].columns) is silently dropped
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this a new bug in dbt-core?
- [x] I believe this is a new bug in dbt-core
- [x] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
When a semantic model is defined using the **new inline `semantic_model:` spec** (dbt 1.12+) on a **versioned model** — i.e. the model's columns live under `versions[].columns` rather than a top-level `columns:` — dbt-core 1.12 **silently produces no semantic model and no metrics** for that model. There is **no error and no warning**; the `semantic_model` block, its entities/dimensions, and its `metrics:` simply do not appear in `manifest.json`.
The same inline spec on a **non-versioned** model works correctly, and **dbt 2.0 / Fusion (`2.0.0-alpha.2`) handles the versioned case correctly** (the semantic model and metric are produced). So this is specific to the dbt-core 1.x parser for the new inline spec.
### Expected Behavior
A semantic model defined inline on a versioned model should either:
1. be parsed correctly (resolving entities/dimensions from the latest version's `columns`, as dbt 2.0 does), or
2. at minimum raise a clear error/warning if the combination is unsupported.
Silently dropping a configured semantic model and its metrics is the problematic part — there is no signal that anything was lost.
### Steps To Reproduce
Minimal project (DuckDB). Four files:
`dbt_project.yml`
```yaml
name: sem_repro
profile: sem_repro
version: "1.0"
model-paths: ["models"]
```
`profiles.yml`
```yaml
sem_repro:
target: dev
outputs:
dev:
type: duckdb
path: dev.duckdb
threads: 1
```
`models/cust_v1.sql` and `models/cust_v2.sql` (identical), `models/nonvers.sql` (identical), and `models/metricflow_time_spine.sql`:
```sql
-- cust_v1.sql / cust_v2.sql / nonvers.sql
select 1 as id, cast('2020-01-01' as date) as created_at
```
```sql
-- metricflow_time_spine.sql
select cast('2020-01-01' as date) as date_day
union all
select cast('2020-01-02' as date) as date_day
```
`models/_models.yml`
```yaml
version: 2
models:
- name: metricflow_time_spine
time_spine:
standard_granularity_column: date_day
columns:
- name: date_day
granularity: day
# Versioned model: columns are under versions[].columns (no top-level columns:)
- name: cust
latest_version: 2
semantic_model:
enabled: true
agg_time_dimension: created_at
metrics:
- name: cust_count
type: simple
agg: count
expr: id
versions:
- v: 1
columns:
- name: id
entity: {type: primary, name: cust}
- name: created_at
granularity: day
dimension: {type: time}
- v: 2
columns:
- name: id
entity: {type: primary, name: cust}
- name: created_at
granularity: day
dimension: {type: time}
# Non-versioned control with the SAME inline semantic spec
- name: nonvers
semantic_model:
enabled: true
agg_time_dimension: created_at
metrics:
- name: nonvers_count
type: simple
agg: count
expr: id
columns:
- name: id
entity: {type: primary, name: nv}
- name: created_at
granularity: day
dimension: {type: time}
```
Then:
```bash
dbt parse
python -c "import json; m=json.load(open('target/manifest.json')); \
print('semantic_models:', sorted(v['name'] for v in m['semantic_models'].values())); \
print('metrics:', sorted(k.split('.')[-1] for k in m['metrics']))"
```
### Relevant log output
```
# dbt-core 1.12.0-b3 (no error, no warning emitted during parse)
semantic_models: ['nonvers']
metrics: ['nonvers_count']
# dbt-core 2.0.0-alpha.2 (same project)
semantic_models: ['cust', 'nonvers']
metrics: ['cust_count', 'nonvers_count']
```
The versioned model `cust` contributes neither a semantic model nor its metric under 1.12, with no diagnostic; both appear under 2.0.
### Environment
```markdown
- OS: Linux
- Python: 3.11
- dbt-core: 1.12.0-b3 (bug present); 2.0.0-alpha.2 (works)
- adapter: dbt-duckdb 1.10.1
```
### Which database adapter are you using with dbt?
duckdb
### Additional Context
Likely cause (from a quick trace of `v1.12.0b3`): in `core/dbt/parser/schema_yaml_readers.py`, `parse_v2_semantic_model_from_dbt_model_patch()` builds entities/dimensions from `patch.columns`, which is empty for a versioned model (its columns are assembled per-version under `versions[].columns`). With no columns, no entities/dimensions are produced and the semantic model is dropped — without raising. (Pointer only; not verified by patch.)
Related: #14600 reports the same YAML shape (inline semantic model on a versioned model) causing a **Fusion** engine panic on `2.0.0-preview.175`. That is a different symptom/engine from this report (dbt-core 1.x silently dropping the model); on the newer `2.0.0-alpha.2` the Fusion side appears to handle it. Cross-linking for context.
Contributor guide
Assessment
This issue has not been assessed yet.