面向 MetricFlow 的开源 OSI Playground
按 Open Semantic Interchange 规范校验 MetricFlow YAML,一键转换成 OSI,并左右对比两种格式的差异。全程在浏览器里运行——不上传,也不用注册。
osi_version: 0.2.0.dev0
entities:
- name: orders
description: Fact table of customer orders
table: fct_orders
join_keys:
- name: order_id
type: primary
- name: customer_id
type: foreign
dimensions:
- name: order_date
type: time
granularity: day
- name: status
type: categorical
metrics:
- name: order_total
type: sum
expr: amount_usd
description: Gross order value in USD
- name: order_count
type: count
expr: order_id
- name: revenue
type: simple
description: Total revenue across all orders
什么是 Open Semantic Interchange?
OSI 是一份面向语义层元数据的厂商中立 YAML 规范——让数仓、BI 工具与 AI Agent 用同一种方式谈论同一个指标,不必在每个产品里重新定义一遍。
OSI 由 Snowflake、dbt Labs、Salesforce、ThoughtSpot 以及 modern data stack 的其他成员于 2025 年发起, 统一了 实体、维度、指标与join key 的描述方式。一旦像 revenue 这样的指标在 OSI 里定义好, Cortex、Cube、Looker、AtScale 与 Datus 就都能读到同一份口径来源。
当前草案是 v0.2.0.dev0。它的目标是随着 Snowflake Cortex 与 dbt 语义层导出的生产落地, 最终演进到 1.0。
MetricFlow → OSI 字段映射
MetricFlow 的每个结构是如何翻译到 OSI 核心 schema 的。上面的转换器用的就是这张表——没有隐藏逻辑。八款产品的完整映射见 OSI 字段映射参考。
| MetricFlow | OSI | 说明 |
|---|---|---|
semantic_models[] | entities[] | One MetricFlow semantic_model becomes one OSI entity — same name, same description. |
model: ref('fct_orders') | table: fct_orders | The dbt ref() wrapper is stripped; the raw table name is used as the OSI table binding. |
entities[] | join_keys[] | primary / foreign / natural key semantics are preserved verbatim. |
dimensions[] | dimensions[] | type is normalized to categorical / time / numeric; time_granularity moves to granularity. |
measures[] | metrics[] (type = agg) | MetricFlow measures become OSI metrics; agg becomes the metric type (sum, count, average…). |
metrics[] (top-level) | metrics[] (on entity) | simple / ratio / cumulative / derived types survive; the referenced measure resolves onto its owning entity. |
想看所有产品的横向对比?阅读 OSI 字段映射参考——MetricFlow、Cube、LookML、AtScale、Snowflake、GoodData、Power BI 与 Databricks,覆盖六个层次。
如何把 MetricFlow 转成 OSI
三步,纯浏览器——不用装 CLI,也不用贴 Key。
贴进你的 MetricFlow YAML
把 semantic_models 文件放进左侧输入框。Playground 在本地解析——什么都不会离开你的浏览器。
转换成 OSI
打开 Converter 标签页,点 Download,就能拿到一份兼容 OSI 的 .yml 文件,可直接交给任何支持 OSI 的工具。
对比并校验
用 Diff 标签页看清楚改了什么,再用 Validator 确认输出符合 OSI v0.2,然后再提交。
开放语义标准为什么重要
当指标定义不再被关在某一家厂商的 YAML 里,你的数据团队当天就能拿到的四个实打实的好处。
一份定义,所有工具通用
让 AI Agent 不再编造指标
零锁定的迁移路径
治理仍然留在它该在的地方
OSI vs MetricFlow vs Cube
交换格式、引擎和平台解决的是不同的问题。这里说明各自的定位。
| 维度 | OSI | MetricFlow | Cube |
|---|---|---|---|
| Scope | Interchange format | Semantic layer + engine | Semantic layer + engine + API |
| Runs queries | No — spec only | Yes (via dbt SQL) | Yes (via Cube API) |
| Vendor | Neutral (Snowflake · dbt · Salesforce · …) | dbt Labs | Cube Dev |
| Primary consumers | BI + AI tools that share a definition | dbt projects + MetricFlow-aware tools | BI dashboards, embedded analytics, LLM apps |
| License | Apache 2.0 | Apache 2.0 | Apache 2.0 |
| Maturity | Draft v0.2 (2026) | GA | GA |
常见问题
OSI 是什么、转换器怎么工作、你的 YAML 是否留在本地,以及 Datus 内部怎么用 OSI。
什么是 Open Semantic Interchange(OSI)?
Open Semantic Interchange 是一份厂商中立的 YAML 规范,用来描述语义层里的指标、维度与实体。它由 Snowflake、dbt Labs、Salesforce 等共同推动,让你只定义一次指标,就能在 Snowflake Cortex、Cube、Looker、AtScale、ThoughtSpot 等工具中查询,不必在每个工具里重新定义一遍「Revenue」。
怎么把 MetricFlow YAML 转成 OSI?
把你的 MetricFlow YAML 贴进上方的 Converter 标签页。Datus OSI Playground 完全在浏览器里运行:它会解析 semantic_models、measures 和 dimensions,映射成 OSI 的 entities、metrics 和 dimensions,然后给你一个可下载的 .yaml 文件,外加一份转换过程中被丢弃字段的清单。
我的 YAML 会被上传到服务器吗?
不会。Validator、Converter 和 Diff 都用 js-yaml 100% 在你的浏览器里运行。语义定义永远不会离开你的机器——没有上传、不用注册、也不记录日志。你可以在浏览器 DevTools 的 Network 面板里自行验证。
Playground 校验的是哪个 OSI 版本?
目前校验的是 OSI v0.2.0.dev0,也就是核心元数据规范的工作草案。OSI 规范仍在向稳定的 1.0 演进,我们会跟进上游 schema,并在规范变动时重新发布 Playground。当前生效的版本会标注在每次校验结果的顶部。
OSI 和 MetricFlow 有什么区别?
MetricFlow 是 dbt Labs 的语义层 YAML 格式——它与 dbt 项目深度耦合,并通过 MetricFlow 引擎生成 SQL。OSI 则是厂商中立的交换格式:它本身不执行查询,只负责标准化指标与维度定义在不同工具之间的共享方式。实践中,团队在 MetricFlow 或 Cube 里编写指标,再导出成 OSI,让下游 BI 与 AI 工具无需绑定厂商即可消费。
Converter 支持 MetricFlow 的全部特性吗?
MVP 覆盖了最常用的部分:semantic_models 转 entities、measures 转 metrics、dimensions 转 dimensions、entities 转 join_keys,以及 type_params.measure 落在已转换模型上的顶层 metrics。高级特性(saved queries、带 grain-to-date 的累计指标、复杂比率指标)还在路线图上;转换中被丢弃的字段都会在结果面板里显式列出,绝不会悄悄丢掉。
Datus 内部怎么用 OSI?
Datus 是一个数据工程 Agent,它会把每一条 SQL 查询、每一条管道、每一个看板答案都锚定在你的语义层上。我们把 OSI 当作 Datus 与你现有语义层之间的中立传输格式——不管是 dbt MetricFlow、Cube、Looker LookML 还是自研的 YAML 存储——这样技术栈变化时 Agent 依然准确。上下文引擎如何读取 OSI,可以看我们的 Features 页面。
OSI Playground 是开源的吗?
上游的 OSI 规范采用 Apache 2.0(github.com/open-semantic-interchange/OSI)。Datus Playground 是 Datus 团队做的免费托管工具——Datus 数据工程 Agent 本身同样是 Apache 2.0,整套系统(含语义层支持)都可以自行部署。
让数据工程 Agent 来读你的 OSI。
Datus 会把每一条 SQL 查询、每一条管道、每一个看板答案都锚定在你的语义层上——OSI、MetricFlow、Cube 或 LookML,随你选。