looker-open-source/looker-skills

lookml-model

Use this skill when you need to create or modify a LookML Model file (.model.lkml).

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/looker-open-source/looker-skills --skill lookml-model

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

Instructions

  1. Define the Model File: A model file generally corresponds to a single database connection and includes Explores.
  2. Required Parameters:
  • connection: "connection_name": Must match a connection defined in Looker Admin.
  • include: "pattern": Specifies which view and dashboard files are available to the model.
  1. Best Practices:
  • Includes: Avoid include: "*.view" if possible to prevent performance issues and namespace clutter. Use specific paths or wildcards like include: "/views/users.view" or include: "/views/marketing/*.view".
  • Label: Use label: to provide a user-friendly name for the model in the UI.
  • Week Start Day: Set week_start_day: if the business logic requires a specific start day (e.g., monday).
  • Datagroups & Caching: ALWAYS use datagroups for caching policies to align Looker with your ETL/ELT processes.

4. Datagroups & Caching

Datagroups are the preferred mechanism for managing caching policies.

  • Definition: Define in the model file.
  • sql_trigger: A query that returns a single value (e.g., max timestamp). If the value changes, the cache is invalidated.
  • max_cache_age: A fallback duration if the trigger doesn't change.
  • persist_with: Apply the datagroup to Explores or the entire model.

Datagroups vs persist_for

FeatureDatagroups (Recommended)persist_for
TriggerSQL Query (Smart)Fixed Time (Dumb)
AlignmentAligns with ETL/ELT completionMisaligned (guesswork)
ManagementCentralized in Model fileScattered in Explores/Models
Use CaseProduction dashboards, ETL synchronizationAd-hoc queries, Real-time (<1h) needs
[!TIP] Use persist_for ONLY for real-time dashboards where you need to force a cache refresh every X minutes (e.g., stock tickers, fast-moving inventory). For everything else, use Datagroups.

5. Include Patterns

Use strict patterns to control scope and performance.

PatternDescriptionUse Case
include: "/views/*.view"All views in specific folderStandard modularity
include: "/views/marketing/users.view"Specific filePrecise control, avoids conflicts
include: "/**/*.view"Recursive (all views in project)Avoid unless small project
include: "/dashboards/*.dashboard"All dashboards in folderImporting dashboards

Examples

Basic Model

lookml
connection: "thelook"

# Include all views in the views/ folder
include: "/views/*.view"

# Include all dashboards
include: "/*.dashboard"

# Define an Explore (usually better to define in separate files for large projects, but acceptable here for small ones)
explore: orders {
  join: users {
    type: left_outer
    sql_on: ${orders.user_id} = ${users.id} ;;
    relationship: many_to_one
  }
}

Model with Specific Settings

lookml
connection: "snowlooker"

label: "eCommerce Analytics"

# Set valid week start day
week_start_day: monday

# Include specific folders
include: "/views/finance/*.view"
include: "/views/marketing/*.view"

Model with Datagroup (Best Practice)

lookml
connection: "thelook"

# Define the caching policy
datagroup: ecommerce_etl {
  description: "Triggers when the max created_at date changes in the events table."
  sql_trigger: SELECT MAX(created_at) FROM `project.dataset.events` ;;
  max_cache_age: "24 hours" # Fallback
}

# Apply default caching to all Explores in this model
persist_with: ecommerce_etl

include: "/views/*.view"

explore: orders {
  # This explore inherits 'persist_with: ecommerce_etl' from the model default
}

explore: real_time_dashboard {
  # Override with a different policy if needed
  persist_for: "5 minutes"
}

관련 작업

같은 저장소의 Skills

더 많은 Skills

모든 Skills