部署配置示例

config/config.yaml 文件(通常从 config/config.yaml.example 模板初始化)用作 Cortex Framework 部署的主要配置。它定义了关键参数,包括目标 Google Cloud 执行项目、源和目标 BigQuery 数据集,以及 Dataform 规范(例如代码库和工作区名称)。

以下部分详细介绍了 config/config.yaml 结构。

构建环境

构建环境项目是指因构建操作(例如 BigQuery 作业 [读取 DD03L])而产生费用的项目。

buildEnvironment:
  buildProjectId: YOUR_BUILD_PROJECT_ID

下表介绍了构建环境参数。

参数 含义 默认值 说明
buildEnvironment.buildProjectId build 项目 ID YOUR_BUILD_PROJECT_ID Google Cloud 执行 build 操作的项目 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 数据集位置(例如 USus-central1europe-west1)。

数据:Cortex 命名空间

定义 Cortex Framework 命名空间。

参数 含义 默认值 说明
data.namespaces.name 命名空间名称 - Cortex Framework 命名空间名称。例如 cortex
data.namespaces.path 命名空间路径 - 用于 src 和 config 文件夹中的子目录的 Cortex Framework 命名空间路径。例如 cortex

数据:BigQuery 源数据集和目标数据集

来源列表定义了 BigQuery 数据集,其中包含已从源系统复制或流式传输到其中的原始数据。

目标定义了将存储 Dataform 处理后的数据集的 BigQuery 数据集列表。

每个来源和目标都通过其唯一 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 Source 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 模块标识符 erp 特定数据基础转换模块实例的唯一标识符。
type 模块逻辑类型 cortex.sap 定义所应用的业务逻辑或模板(例如,客户、销售文档)。
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 客户端标识符。
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 模块标识符 - 特定转换模块实例的唯一标识符。
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 管理 Dataform 代码库的 Google Cloud 项目 ID。
targetSettings.repositoryRegion 代码库区域 us-central1 Dataform 代码库的 Google Cloud 区域(例如 us-central1europe-west1)。
targetSettings.repositoryName 代码库名称 cortex-repository Dataform 代码库的具体名称。
targetSettings.workspaceName 工作区名称 dev 用于部署周期的特定 Dataform 工作区。