# LookML

**LookML**（Looker 建模语言，Looker Modeling Language）是谷歌云（Google Cloud）商业智能平台 Looker 使用的专有数据建模语言，用于在 SQL 数据库之上定义语义数据模型。用 LookML 编写的模型描述维度、聚合、计算和数据关系；Looker 的 SQL 生成器会把针对该模型发出的查询转换为针对所连接数据库的 SQL，因此业务用户无需自己编写 SQL 就能查询数据。<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup>

| 关键事实 | 详情 |
|---|---|
| 全称 | Looker 建模语言，即 Looker 中用于创建语义数据模型的语言<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup> |
| 起源 | 由 Looker 联合创始人劳埃德·塔布（Lloyd Tabb）创建，他此前曾任网景（Netscape）首席工程师和 LiveOps 首席技术官<sup>[2](https://www.enterpriseappstoday.com/news/business-intelligence-startup-looker-raises-16m.html)</sup> |
| 首次发布 | 在 Looker 1.10.13（2012年11月）中被描述为一种基于 YAML 的语言；新的非 YAML 语法随 Looker 4.0（2016年10月）推出<sup>[3](https://docs.cloud.google.com/looker/docs/looker-1-release-notes)</sup><sup> • </sup><sup>[4](https://docs.cloud.google.com/looker/docs/looker-4-release-notes)</sup> |
| 设计 | 像 make 一样的依赖语言，而非命令式语言；不依赖特定 SQL 方言<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup> |
| 核心元素 | 模型、Explore、视图、维度和度量；项目通常通过 Git 进行版本控制<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup><sup> • </sup><sup>[5](https://docs.cloud.google.com/looker/docs/lookml-terms-and-concepts)</sup> |
| 所有权 | 归 Looker 专有；谷歌于2019年6月以26亿美元收购 Looker<sup>[6](https://www.techtarget.com/data-technologies/news/252483232/Looker-analytics-platform-adding-app-development-capability)</sup><sup> • </sup><sup>[7](https://www.dataarchitect.co/blog/semantic-layer-tools)</sup> |
| 可移植性 | 开放 SQL 接口（Open SQL Interface，2024年8月）允许其他工具查询 LookML 模型，但仅限连接到 BigQuery 的模型<sup>[8](https://cloud.google.com/blog/products/business-intelligence/opening-up-the-looker-semantic-layer)</sup> |

## 目的与设计

LookML 的存在，是为了让分析团队对业务指标拥有单一、集中化的定义。数据分析师只需在一个地方编写一次 SQL 表达式，Looker 便复用这段代码来生成临时 SQL 查询；文档称这种做法为 DRY（“不要重复自己”）风格。业务用户随后在 Looker 的 Explore 界面中构建查询，选择维度、度量和筛选条件，而无需看到底层 SQL 结构。<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup>

LookML 是一种依赖语言，谷歌云文档将其与 make 类比，而不是与 C 或 Ruby 这类命令式语言类比。它为数据建模提供预定义的数据类型和语法，并封装 SQL 表达式，使同一个模型能够支持任何 SQL 实现。<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup> 在早期公司材料中，该语言被描述为面向对象，旨在简化 SQL 查询的脚本编写与复用，并且按照当时公司的说法，几乎消除工程师直接编写 SQL 的需要。<sup>[2](https://www.enterpriseappstoday.com/news/business-intelligence-startup-looker-raises-16m.html)</sup>

LookML 有意将查询结构与查询内容分离：表如何连接，与访问哪些列、计算哪些派生字段以及应用哪些筛选条件相互独立。<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup>

## LookML 项目的结构

LookML 以项目为组织单位。项目是一组文件的集合，至少包括模型文件和视图文件，通常通过一个 Git 仓库一起进行版本控制。<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup> 文档中的一个最小示例包含一个模型文件 `ecommercestore.model.lkml`，以及两个视图文件 `orders.view.lkml` 和 `customers.view.lkml`。<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup>

**模型文件。** 模型指定项目使用哪个数据库连接、包含哪些文件，以及将使用哪些表以及这些表应如何连接。在 Looker 中，模型是控制逻辑并为用户把关数据访问的语义层。<sup>[5](https://docs.cloud.google.com/looker/docs/lookml-terms-and-concepts)</sup>

**Explore。** `explore` 在模型文件中声明，定义用户可用的查询选项。用 SQL 术语来说，一个 Explore 相当于查询的 `FROM` 子句，而其 `join` 声明指定视图之间如何关联，例如 `sql_on: ${orders.customer_id} = ${customers.id}`。<sup>[5](https://docs.cloud.google.com/looker/docs/lookml-terms-and-concepts)</sup>

**视图、维度与度量。** 视图定义一组字段，以及这些字段与底层表或派生表的关联。字段大多是维度和度量。维度是可分组字段，用于对结果分桶或筛选；维度始终出现在生成 SQL 的 `GROUP BY` 子句中。度量使用 `COUNT`、`SUM`、`AVG`、`MIN` 或 `MAX` 等 SQL 聚合函数，任何由其他度量计算得到的字段也是度量。<sup>[5](https://docs.cloud.google.com/looker/docs/lookml-terms-and-concepts)</sup>

当用户在 Explore 界面中构建查询时，Looker 会将其发送给 SQL 生成器；生成器把查询转换为 SQL，在数据库上执行，并返回格式化结果用于可视化。<sup>[1](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)</sup>

## 派生表与性能

LookML 允许定义派生表，即用 SQL 定义、而非直接绑定到物理表的表。派生表可以定义行的一个子集，其 SQL 查询可以引用数据模型中的任何视图，包括其他派生表。<sup>[9](https://deepscienceresearch.com/dsr/catalog/download/258/1325/2646?inline=1)</sup> 持久化派生表（Persistent Derived Tables，PDT）在 1.x 版本中引入，将这些结果物化到数据库中，使重复查询无需重新计算它们。<sup>[3](https://docs.cloud.google.com/looker/docs/looker-1-release-notes)</sup>

LookML 校验器（LookML Validator）于 Looker 3.6（2014年11月）加入，可一次性检查整个项目的 LookML 问题，而不是逐文件检查。<sup>[10](https://docs.cloud.google.com/looker/docs/looker-3-release-notes)</sup>

## 历史

Looker 成立于2012年6月，并于次年3月推出，当时已有20多家付费客户；LookML 当时被描述为一种专有数据建模语言，从一开始就是其方法的核心。<sup>[2](https://www.enterpriseappstoday.com/news/business-intelligence-startup-looker-raises-16m.html)</sup> 2012年11月的 Looker 1.10.13 发行说明统一了术语，将 LookML 定义为“基于 YAML 的 Looker 语言，可为给定数据库连接定义逻辑业务模型”，并同时定义了字段、维度、度量、视图和模型这些术语。<sup>[3](https://docs.cloud.google.com/looker/docs/looker-1-release-notes)</sup>

语法在 Looker 4.0（2016年10月）中发生了重大变化。新的 LookML 保留了 YAML 风格的传承，但不再采用基于缩进的层级结构，允许更一致的引号与列表定义，并让语言能够感知自身的规则，例如维度不能带有 `type: sum`。<sup>[4](https://docs.cloud.google.com/looker/docs/looker-4-release-notes)</sup> 谷歌于2019年6月以26亿美元收购 Looker，<sup>[6](https://www.techtarget.com/data-technologies/news/252483232/Looker-analytics-platform-adding-app-development-capability)</sup> 并于2022年统一 Looker 平台，将 Looker、Looker Studio 和嵌入式 Looker 纳入其中，使它们都能原生访问 LookML 语义层。<sup>[11](https://s3.eu-central-1.amazonaws.com/victa-2022/media/Qlik/Gartner/Victa-Gartner_2023-report.pdf)</sup>

## 在语义层中的位置

评论者将 LookML 归类为 BI 原生的语义层：定义位于一个分析平台内部，而不是作为独立服务存在。<sup>[7](https://www.dataarchitect.co/blog/semantic-layer-tools)</sup> 各类评估一致指出其成熟度和功能深度，称道其出色的访问控制、派生表以及用于动态 SQL 的 Liquid 模板，同时也提到 Looker 许可成本和专有语言带来的锁定：迁移到其他 BI 工具意味着重写所有 LookML 定义。<sup>[7](https://www.dataarchitect.co/blog/semantic-layer-tools)</sup> Looker 的受治理自助服务模式——业务用户在 LookML 模型设定的限制内进行探索——被一些评论者评为 BI 工具中最强的模式。<sup>[7](https://www.dataarchitect.co/blog/semantic-layer-tools)</sup> 它还会重复团队越来越多地放在 dbt 中的转换逻辑，批评者将此描述为定义又多了一个存在并发生漂移的地方。<sup>[12](https://github.com/hong-chu/dbt-semantic-wiki/blob/main/wiki/comparisons/semantic-layer-options.md)</sup>

**开放该层。** 2024年8月，谷歌发布了开放 SQL 接口，这是一个基于 BigQuery 的 LookML 模型集成层，同时发布了面向 Tableau、Power BI、Google Sheets、Looker Studio、ThoughtSpot、Mode 等工具的连接器，以及一个通用 [JDBC 驱动](https://www.edgepedia.org/zh/jdbc-driver)程序。每个连接器都支持任何连接到 BigQuery 的 LookML 模型。<sup>[8](https://cloud.google.com/blog/products/business-intelligence/opening-up-the-looker-semantic-layer)</sup> 第三方报道指出了同样的 BigQuery 限制：该接口和连接器让外部工具可以查询 LookML 模型，但仅限于连接到 BigQuery 的模型。<sup>[13](https://upsolve.ai/blog/semantic-layer-tools)</sup>

**AI 集成。** Looker 的对话式分析（Conversational Analytics）以 LookML 为基础，谷歌还提供一个由 Looker 管理的 MCP 服务器（MCP，即[模型上下文协议](https://www.edgepedia.org/zh/model-context-protocol)（Model Context Protocol），是 AI 代理用来连接工具的开放标准）。<sup>[14](https://www.thirdbrain.tech/KB-TECH/DATA-PLATFORMS/semantic-layers-compared)</sup> 适用于 VS Code 的 Looker 扩展自2026年9月起全面可用，支持借助 MCP 在 AI 辅助下进行本地 LookML 开发。<sup>[15](https://docs.cloud.google.com/looker/docs/release-notes)</sup> 谷歌还将 LookML 元数据索引到知识目录（Knowledge Catalog）中，使代理能够在查询数据之前验证经过认证的 LookML 模型，并将自然语言问题映射到确切的 LookML 维度和度量。<sup>[16](https://cloud.google.com/blog/products/business-intelligence/lookml-metadata-indexing-in-knowledge-catalog-is-now-ga/)</sup>

## References

1. [Introduction to LookML, Looker, Google Cloud Documentation](https://docs.cloud.google.com/looker/docs/what-is-lookml?hl=en)
2. [Business Intelligence Startup Looker Raises $16M, Enterprise Apps Today (2013)](https://www.enterpriseappstoday.com/news/business-intelligence-startup-looker-raises-16m.html)
3. [1.x Release Notes, Looker, Google Cloud Documentation](https://docs.cloud.google.com/looker/docs/looker-1-release-notes)
4. [4.x Release Notes, Looker, Google Cloud Documentation](https://docs.cloud.google.com/looker/docs/looker-4-release-notes)
5. [LookML terms and concepts, Looker, Google Cloud Documentation](https://docs.cloud.google.com/looker/docs/lookml-terms-and-concepts)
6. [Looker analytics platform adding app development capability, TechTarget (2020)](https://www.techtarget.com/data-technologies/news/252483232/Looker-analytics-platform-adding-app-development-capability)
7. [Semantic Layer Tools Compared: dbt Semantic Layer, Cube, AtScale, and LookML, DataArchitect.co (2026)](https://www.dataarchitect.co/blog/semantic-layer-tools)
8. [Looker opens semantic layer via new SQL Interface and connectors for Tableau & others, Google Cloud Blog (August 14, 2024)](https://cloud.google.com/blog/products/business-intelligence/opening-up-the-looker-semantic-layer)
9. [Business Intelligence with LookML (derived tables), Deep Science Research](https://deepscienceresearch.com/dsr/catalog/download/258/1325/2646?inline=1)
10. [3.x Release Notes, Looker, Google Cloud Documentation](https://docs.cloud.google.com/looker/docs/looker-3-release-notes)
11. [Victa-Gartner 2023 report on Looker (Qlik-hosted PDF)](https://s3.eu-central-1.amazonaws.com/victa-2022/media/Qlik/Gartner/Victa-Gartner_2023-report.pdf)
12. [Semantic Layer Options: dbt SL vs Cube vs Warehouse-Native vs LookML vs AtScale, dbt-semantic-wiki (GitHub)](https://github.com/hong-chu/dbt-semantic-wiki/blob/main/wiki/comparisons/semantic-layer-options.md)
13. [Semantic Layer Tools: 14 Compared for BI & AI (2026), Upsolve](https://upsolve.ai/blog/semantic-layer-tools)
14. [Semantic layers compared (October 2026), ThirdBrain](https://www.thirdbrain.tech/KB-TECH/DATA-PLATFORMS/semantic-layers-compared)
15. [Looker release notes, Google Cloud Documentation](https://docs.cloud.google.com/looker/docs/release-notes)
16. [LookML metadata indexing in Knowledge Catalog is now GA, Google Cloud Blog](https://cloud.google.com/blog/products/business-intelligence/lookml-metadata-indexing-in-knowledge-catalog-is-now-ga/)

---
*Initially written Oct 26, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Data mining, warehousing, and big data › Data warehousing

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/lookml

English original: https://www.edgepedia.org/lookml
