Nghiên cứu tình huống: Xây dựng mô hình dữ liệu E-Commerce với dbt
Susan Sun
Freelance Data Scientist
_<data source>__<asset>.yml
looker_ecommerce/
macros/
models/
_looker__models.yml <------
_looker__sources.yml <------
stg_looker__distribution_center.sql
stg_looker__orders.sql
seeds/
looker__distribution_center.csv
Ví dụ _looker__models.yml:
version: 2
models:
- name: model_name
description: Đây là một bảng
columns:
- name: column_name
description: Đây là một cột
- name: column_name
description: Đây là một cột
Lưu ý:
version: 2 là định dạng cấu hình schema dbt dùngmodels xác định asset được mô tả1.unique: mỗi giá trị dòng là duy nhất
- name: table_name
columns:
- name: column_name
data_tests:
- not_null
...
2.not_null: không dòng nào được null
- name: table_name
columns:
- name: column_name
data_tests:
- unique
- not_null
- name: column_name
data_tests:
- unique
3.accepted_values: chỉ chấp nhận các giá trị trong danh sách
- name: table_name
columns:
- name: column_name
data_tests:
- accepted_values:
values: ['value_a', 'value_b', 'value_c', NULL]
4.relationships: toàn vẹn tham chiếu (khóa ngoại) giữa các bảng
- name: table_1
columns:
- name: column_1
data_tests:
- relationships:
to: ref('table_2')
field: column_2
Nghiên cứu tình huống: Xây dựng mô hình dữ liệu E-Commerce với dbt