모델 속성
모델 속성 (Model properties)
모델 속성은 models/ 디렉터리(model-paths config로 정의)의 .yml 파일에 선언할 수 있어요. 이 페이지는 최신 YAML 스펙에서 사용할 수 있는 최상위 모델 속성을 정리해 드릴게요.
출처: 문서
본문
모델 속성은 models/ 디렉터리(model-paths config로 정의)의 .yml 파일에 선언할 수 있어요.
이 파일들은 whatever_you_want.yml로 이름을 지을 수 있고, models/ 디렉터리 안에서 원하는 만큼 깊게 중첩할 수 있어요.
가용성 (Availability) — 최신 YAML 스펙은 다음 환경에서 지원돼요:
- dbt 플랫폼 (v1 Latest release track)
- dbt v2
- dbt v1.12
자세한 내용은 Migrate to the latest YAML spec 문서를 참고하세요.
사용 가능한 최상위 모델 속성 (Available top-level model properties)
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | The model name (must match the model filename). |
| description | string | No | Documentation for the model. |
| columns | array | No | List of column definitions. |
| config | object | No | Model configuration (materialization, tags, etc.). |
| constraints | array | No | Model-level constraints (primary key, foreign key, etc.). |
| data_tests | array | No | Model-level data tests. |
| tests | array | No | Legacy alias for data_tests. |
| versions | array | No | Model version definitions. |
| latest_version | string/float | No | The latest version of the model. |
| deprecation_date | string | No | Date when the model is deprecated. |
| access | string | No | Access level: private, protected, or public. Supported at the top-level for backwards compatibility only. |
| time_spine | object | No | Time spine configuration for the Semantic Layer. |
| semantic_model | object | No | Latest YAML spec only. Enable semantic model configuration for the Semantic Layer with enabled: true. For other properties, refer to Semantic model properties. |
| metrics | array | No | Latest YAML spec only. Metrics derived from this semantic model; list is alongside (not under) semantic_model and columns. For other properties, refer to Metric properties. |
(dbt v1.12 이상) 예시 파일 (최신)
최신 YAML 스펙에는 semantic_model:, 최상위 agg_time_dimension과 primary_entity, 그리고 metrics: 같은 Semantic Layer 속성이 포함돼요. 컬럼은 entity:와 dimension: 블록 및 시간 차원의 granularity를 포함할 수 있어요. 전체 구조는 Semantic model properties와 Metric properties를 참고하세요.
models/
models:
# Model name must match the filename of a model -- including case sensitivity
- name: model_name
description: <markdown_string>
latest_version: <version_identifier>
deprecation_date: <YAML_DateTime>
config:
<model_config>: <config_value>
docs:
show: true | false
node_color: <color_id> # Use name (such as node_color: purple) or hex code with quotes (such as node_color: "#cd7f32")
access: private | protected | public
constraints:
- <constraint>
data_tests:
- <test>
- ... # declare additional data tests
columns:
- name: <column_name> # required
description: <markdown_string>
quote: true | false
constraints:
- <constraint>
data_tests:
- <test>
- ... # declare additional data tests
config:
meta: {<dictionary>}
tags: [<string>]
# only required in conjunction with time_spine key
granularity: <any supported time granularity>
# In the latest YAML spec, a column can optionally include an entity or dimension block for Semantic Layer.
#
# entity:
# type: primary | foreign | unique | natural
# name: <entity_name>
# dimension:
# type: time | categorical
# name: <dimension_name>
- name: ... # declare properties of additional columns
time_spine:
standard_granularity_column: <column_name>
# Latest YAML spec only: semantic model and metrics on the model
semantic_model:
enabled: true
name: <semantic_model_name>
agg_time_dimension: <time_dimension_name> # top-level; references dimension name
primary_entity: <primary_entity_name> # optional; use when no column has type: primary
metrics:
- name: <metric_name>
type: simple | cumulative | ratio | derived | conversion
# ... type-specific properties; see Metric properties
versions:
- v: <version_identifier> # required
defined_in: <definition_file_name>
description: <markdown_string>
constraints:
- <constraint>
config:
<model_config>: <config_value>
docs:
show: true | false
access: private | protected | public
data_tests:
- <test>
- ... # declare additional data tests
columns:
# include/exclude columns from the top-level model properties
- include: <include_value>
exclude: <exclude_list>
# specify additional columns
- name: <column_name> # required
quote: true | false
constraints:
- <constraint>
data_tests:
- <test>
- ... # declare additional data tests
tags: [<string>]
- v: ... # declare additional versions
더 알아보기 (Learn more)
- Models — 모델 빌드
- Semantic model properties — 시맨틱 모델 속성
- Metric properties — 메트릭 속성