On Snowflake, a table created by a tool that quotes its column names has columns like "status" or
"eventDate". A semantic model on that table validates in YAML, and then the warehouse check or the first
query fails with invalid identifier 'STATUS': MetricFlow wrote status without quotes, and Snowflake
reads an unquoted name as uppercase.
Copy and paste
The fix that lasts: rename in the dbt model the semantic model sits on:
-- models/marts/events.sql
select
"event_id" as event_id,
"customer_id" as customer_id,
"eventDate" as event_date,
"status" as status,
"amount" as amount
from {{ ref('stg_events') }}
Every column is now an ordinary uppercase Snowflake column, and the semantic model uses plain names.
If you can’t change the model: put the quoted name in an expr.
models:
- name: raw_events
semantic_model:
enabled: true
agg_time_dimension: event_date
derived_semantics:
entities:
- name: event
type: primary
expr: '"event_id"'
- name: customer
type: foreign
expr: '"customer_id"'
dimensions:
- name: event_date
type: time
granularity: day
expr: '"eventDate"'
- name: status
type: categorical
expr: '"status"'
metrics:
- name: event_amount
type: simple
agg: sum
expr: '"amount"'
The single quotes are YAML; the double quotes go into the SQL.
quote: true doesn’t help here
dbt’s column property quote: true makes tests and documentation quote a column. MetricFlow ignores it.
With status declared on the column with quote: true, the generated SQL was:
SELECT
DATE_TRUNC('year', "eventDate") AS metric_time__year
, status AS event__status
, "amount" AS __event_amount
FROM "shop"."main"."raw_events" raw_events_src_10000
"eventDate" and "amount" came from expr and kept their quotes; status came from the column and lost
them. On Snowflake that line fails. Every column the semantic model reads therefore has to be either
uppercase-compatible or quoted inside an expr.
Why a column-level dimension can’t do it
In the latest YAML spec, a column-level dimension: block accepts no expr; computed or quoted
dimensions go under derived_semantics, as above. The same applies to entities on such columns.
Which to choose
Renaming in the model is better: the table becomes usable from every tool, the semantic model stays
readable, and dbt’s tests on the model need no quoting. Keep expr with quotes for tables you don’t own,
such as a source exposed directly. The general Snowflake rules are in
how to query lowercase quoted columns from dbt in Snowflake.
The generated SQL was checked with dbt Core 1.12 and MetricFlow 0.213 on DuckDB, which doesn’t reproduce Snowflake’s case rules; Snowflake’s behaviour comes from its documentation.