部署設定範例
config/config.yaml 檔案 (通常是從 config/config.yaml.example 範本初始化) 是 Cortex Framework 部署作業的主要設定。這個檔案定義重要參數,包括目標執行專案、來源和目的地 BigQuery 資料集,以及 Dataform 規格,例如存放區和工作區名稱。 Google Cloud
以下各節將詳細說明 config/config.yaml 結構。
建構環境
建構環境專案是指會針對建構動作 (例如 BigQuery 工作 (讀取 DD03L)) 收費的專案。
buildEnvironment:
buildProjectId: YOUR_BUILD_PROJECT_ID
下表說明建構環境參數。
| 參數 | 意義 | 預設值 | 說明 |
|---|---|---|---|
buildEnvironment.buildProjectId |
建構專案 ID | YOUR_BUILD_PROJECT_ID |
Google Cloud 執行建構作業的專案 ID。 |
資料
設定檔的 data: 區段會定義資料來源、目標,以及資料基礎和資料產品的特定模組。
一般結構如下:
data:
# Geographic location for BigQuery datasets (for example: US, EU, us-central1)
# For full list see: https://docs.cloud.google.com/cortex/docs/supported-locations
bigQueryLocation: US
# List of namespaces for data foundation and product modules.
namespaces:
- name: cortex
path: cortex
# List of source datasets.
sources:
- ...
# List of target datasets.
targets:
- ...
# Configuration for data foundation and product modules.
modules:
# List of foundation modules.
foundation:
- ...
# List of data product modules.
product:
- ...
資料:BigQuery 位置
定義 BigQuery 來源和目標資料集的位置。
| 參數 | 意義 | 預設值 | 說明 |
|---|---|---|---|
data.bigQueryLocation |
BigQuery 位置 | US |
BigQuery 資料集位置 (例如 US、us-central1 或 europe-west1)。
|
資料:Cortex 命名空間
定義 Cortex Framework 命名空間。
| 參數 | 意義 | 預設值 | 說明 |
|---|---|---|---|
data.namespaces.name |
命名空間名稱 | - | Cortex Framework 命名空間名稱。例如 cortex。 |
data.namespaces.path |
命名空間路徑 | - | src 和 config 資料夾中使用的子目錄的 Cortex Framework 命名空間路徑。例如 cortex。 |
資料:BigQuery 來源和目標資料集
來源清單會定義 BigQuery 資料集,其中包含從來源系統複製或串流的原始資料。
目標會定義 BigQuery 資料集清單,用來儲存 Dataform 處理的資料集。
模組會使用專屬 ID 參照來源和目標。
# Data source and target mapping
sources:
- id: sap_raw
projectId: YOUR_SOURCE_PROJECT_ID
datasetId: cortex_sap_raw
targets:
- id: sap_foundation
projectId: YOUR_TARGET_PROJECT_ID
datasetId: cortex7_sap_data_foundation
下表說明資料來源和目標對應參數。
| 參數 | 意義 | 預設值 | 說明 |
|---|---|---|---|
data.sources.id |
來源 ID | - |
定義要從中提取資料的來源資料集「ID」。例如 sap_raw。 |
data.sources.projectId |
來源專案 ID | YOUR_SOURCE_PROJECT_ID |
參照具有來源資料的 Google Cloud 專案 ID。 |
data.sources.datasetId |
來源 BigQuery 資料集 ID | - |
參照含有來源資料的 BigQuery 資料集 ID。例如 cortex_sap_raw。 |
data.targets.id |
目標 ID | - | 定義目標資料集的「id」。例如 cortex_data_foundation。 |
data.targets.projectId |
目標專案 ID | YOUR_TARGET_PROJECT_ID |
參照目標資料的 Google Cloud 專案 ID。 |
data.targets.datasetId |
目標 BigQuery 資料集 ID | - |
參照目標資料的 BigQuery 資料集 ID。例如 cortex_sap_data_foundation。 |
資料:模組
模組會定義 Dataform 資料管道的結構和元件。
資料:模組:基礎
本節會設定資料基礎層模組,將原始層 (CDC 串流) 的資料處理為來源資料的標準化最新記錄表示法。如果來源直接提供最新記錄的檢視畫面,或這類轉換是由來源系統連接器執行,則模組可設定為外部資料基礎來源。
modules:
# List of foundation modules.
foundation:
# Unique identifier for the module instance.
- moduleId: erp
# Type of the module (namespaced, for example, cortex.sap).
type: cortex.sap
# Reference to the source dataset ID.
dataSourceId: sap_raw
# Reference to the target dataset ID.
dataTargetId: sap_foundation
# Module-specific configuration settings.
moduleSettings:
# SAP version (for example, ecc, s4).
sapVersion: ecc
# SAP client number.
mandt: "100"
# Whether the module is enabled.
# enabled: true
# Whether the foundation is external (does not create target dataset).
# external: false
# Path to the table settings configuration file.
# tableSettings: "config/data_foundation/sap/table_settings.yaml"
下表說明 modules.foundation 設定的資料基礎模組參數。
| 參數 | 意義 | 預設值 | 說明 |
|---|---|---|---|
moduleId |
模組 ID | erp |
特定資料基礎轉換模組執行個體的專屬 ID。 |
type |
模組邏輯類型 | cortex.sap |
定義套用的商業邏輯或範本 (例如 customers、sales_documents)。 |
dataSourceId |
來源連結 | sap_raw |
參照 data.sources 清單中的「id」,從中擷取資料。 |
dataTargetId |
目標連結 | sap_foundation |
從目標清單參照「id」,將資料推送至該目標。 |
moduleSettings.sapVersion |
SAP 系統版本 | ecc |
僅適用於 SAP 資料來源。決定 ecc (ECC) 或 s4 (S/4HANA) 系統的來源專屬邏輯。 |
moduleSettings.mandt |
SAP 用戶端 (Mandant) | 100 |
僅適用於 SAP 資料來源。用於篩選資料列的 3 位數 SAP 用戶端 ID。 |
enabled |
啟用模組 | true |
指定是否啟用模組。 |
external |
外部基礎 | false |
指定基礎是否為外部 (不會建立目標資料集)。 |
tableSettings |
資料表設定 | config/cortex/data_foundation/{source_system}/table_settings.yaml |
資料表設定設定檔的路徑。 |
資料:模組:資料產品
資料產品模組會定義匯總、計算和聯結,將原始資料轉換為可滿足特定業務用途的洞察資料。
設定資料產品時,可以設定專屬 ID、定義依附元件,以及參照資料基礎模組和目標資料集 (結果會儲存在其中)。
特定資料產品的詳細設定定義在鍵 tableSettings 參照的檔案中。
modules:
# List of data product modules.
product:
# Unique identifier for the data product instance.
- moduleId: sap_purchasing_organizations
# Type of the data product (namespaced).
type: cortex.purchasing_organizations
# Map of module dependencies.
dependsOn:
sapModule: erp
# Reference to the target dataset ID.
dataTargetId: product_target
# Whether the module is enabled.
# enabled: true
# Path to the table settings configuration file.
# tableSettings: "config/cortex/data_product/purchasing_organizations/table_settings.yaml"
下表說明 modules.product 設定的資料產品模組參數。
| 參數 | 意義 | 預設值 | 說明 |
|---|---|---|---|
moduleId |
模組 ID | - | 特定轉換模組執行個體的專屬 ID。 |
type |
模組邏輯類型 | - | 定義套用的商業邏輯或範本,定義於 src/data_modules/{namespace}/data_product 資料夾中。 |
dataTargetId |
目標連結 | sap_foundation |
從目標清單參照「id」,將資料推送至該目標。 |
dependsOn |
上游依附元件 | sapModule: erp |
指定產品模組建構前必須存在的基礎模組。 |
enabled |
啟用模組 | true |
指定是否啟用模組。 |
tableSettings |
資料表設定 | "config/{namespace}/data_product/data_product_name/table_settings.yaml" |
資料表設定設定檔的路徑。 |
部署環境
Cortex Framework 會使用 Dataform,在 BigQuery 中協調 SQL 轉換作業。deployment: 區塊會定義 Dataform 設定,負責執行資料管道,包括存放區專案、位置、存放區名稱和 Dataform 工作區名稱。
deployment:
targets:
- type: dataform
enabled: true
targetSettings:
repositoryProjectId: YOUR_REPO_PROJECT_ID
repositoryRegion: us-central1
repositoryName: cortex-repository
workspaceName: dev
下表說明部署目標位置參數 (deployment.targets:)。
| 參數 | 意義 | 預設值 | 說明 | Google Cloud
|---|---|---|---|
type |
部署作業類型 | dataform |
部署目標的類型。 |
enabled |
啟用/ 停用 | true |
指定是否啟用或停用指定部署目標。 |
targetSettings.repositoryProjectId |
存放區專案 ID | YOUR_REPO_PROJECT_ID |
Google Cloud 管理 Dataform 存放區的專案 ID。 |
targetSettings.repositoryRegion |
存放區區域 | us-central1 |
Dataform 存放區的 Google Cloud 區域 (例如 us-central1 或 europe-west1)。 |
targetSettings.repositoryName |
存放區名稱 | cortex-repository |
Dataform 存放區的具體名稱。 |
targetSettings.workspaceName |
工作區名稱 | dev |
用於部署週期的特定 Dataform 工作區。 |