一键导入
lookml-tests
Standards and best practices for writing LookML tests to ensure data integrity, accuracy, and logic validation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Standards and best practices for writing LookML tests to ensure data integrity, accuracy, and logic validation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Design and implementation of high-quality Looker dashboards using LookML. Covers layout optimization, KPI comparisons, mixed series charts, advanced markdown styling, and performance best practices.
Use this skill to create Access Grants for row-level or object-level security.
Use this skill when you need to create or modify a LookML Explore. This includes defining the Explore, joins, access grants, and basic configuration.
Overview of LookML field types (Dimension, Measure, Filter, Parameter) and the role of the `sql` parameter in each. Use this skill to choose the right field type for your data modeling needs.
Use this skill to use Liquid variables in LookML for dynamic SQL, HTML, and Links, including advanced patterns for query optimization.
Use this skill when you need to create or modify a LookML Model file (.model.lkml). This includes defining connections, includes, and configuring model-level settings.
| name | lookml-tests |
| description | Standards and best practices for writing LookML tests to ensure data integrity, accuracy, and logic validation. |
Testing is critical for maintaining trust in data. LookML tests allow us to verify that our semantic model behaves as expected and that the underlying data conforms to our assumptions.
tests/[explore_name].test.lkml.[explore_name].test.lkml (e.g., orders.test.lkml).Each test consists of an explore_source query and an assert statement.
test: [test_name] {
explore_source: [explore_name] {
column: [column_name] { field: [view_name].[field_name] }
filters: {
field: [view_name].[field_name]
value: "[value]"
}
}
assert: [assertion_name] {
expression: ${[view_name].[field_name]} [operator] [value] ;;
}
}
Verify that Primary Keys remain unique after joins. This is the best defense against "fanout" errors caused by incorrect one_to_many join definitions.
Example: Primary Key Uniqueness
test: orders_pk_is_unique {
explore_source: orders {
column: order_id {}
column: count {}
# Limit to recent data to save costs/time if table is large
filters: {
field: orders.created_date
value: "last 7 days"
}
}
assert: order_id_is_unique {
expression: ${orders.count} = 1 ;;
}
}
Validate specific measure values against known constants or expectations.
Example: Revenue is Positive
test: revenue_is_positive {
explore_source: orders {
column: total_revenue {}
filters: {
field: orders.created_date
value: "yesterday"
}
}
assert: revenue_greater_than_zero {
expression: ${orders.total_revenue} >= 0 ;;
}
}
Ensure calculations behave as expected. For example, checking that gross_margin is never greater than revenue or that lifetime_orders is never NULL for an active user.
Example: Logic Check
test: margin_less_than_revenue {
explore_source: orders {
column: total_revenue {}
column: total_margin {}
}
assert: margin_is_valid {
expression: ${orders.total_margin} <= ${orders.total_revenue} ;;
}
}
orders_pk_is_unique) and assertions (order_id_is_unique).last 7 days) to limit the scan size for large tables, unless verifying full history is required.test files are included in the model file (e.g., include: "/tests/*.test.lkml").