SAP Business Data Cloud 集成
Google Cloud Cortex Framework 使用 BigLake Delta Sharing (lakehouse_delta_share) 连接到 SAP Business Data Cloud (SAP BDC),因此您可以直接在 BigQuery 中查询受治理的 SAP 数据产品,而无需复制数据,并将其联接到下游分析模型中。
该集成结合了以下核心机制:
- 零复制联合查询:SAP BDC 通过 Delta Sharing 端点发布精选数据产品,BigQuery 通过 Google Cloud BigLake 目录就地查询这些产品。
- 声明式目录注册:您可以使用
type: lakehouse_delta_share在config/config.yaml中的data.modules.catalogs下注册 SAP BDC 目录一次。 - 逻辑依赖项绑定:下游数据产品使用两部分 (
<catalog_id>.<schema_name>) 或三部分 (<catalog_id>.<share_id>.<schema_name>) 绑定将逻辑输入绑定到特定 Delta Sharing 架构,而无需在 SQL 中对特定于环境的目录路径进行硬编码。
混合企业架构和应用场景
将 SAP BDC 与 Cortex Framework 集成支持以下企业架构模式:
- 集中式治理和编排:通过单个
config/config.yaml文件管理联合 SAP BDC 输入、一致的基础表和下游使用视图。Cortex Framework 会编译统一的 Dataform DAG,强制执行数据质量断言,并将业务元数据发布到 Knowledge Catalog。 - 统一的混合 SAP 环境:协调通过 SAP BDC 共享公开的旧版 SAP ECC、现代 SAP S/4HANA 和独立 SAP Business Warehouse (SAP BW) 系统中的数据,以及原始复制的 SAP ERP 数据基础。
- 跨平台复合数据产品:将 SAP BDC 共享与 Salesforce CRM 基础或 BigQuery 共享中的外部零复制数据集(例如 Google WeatherNext 预测或 Dun & Bradstreet 运输情报)相结合,提供跨领域的供应链、财务和销售数据洞见。
SAP BDC 的前提条件
在 Cortex Framework 中配置 SAP BDC 之前,请在 Google Cloud 和 SAP 中完成以下设置步骤:
- 在目录宿主项目中启用所需的 Google Cloud API:
biglake.googleapis.com、bigquery.googleapis.com、bigqueryreservation.googleapis.com和cloudresourcemanager.googleapis.com(并在 Dataform 代码库项目中启用dataform.googleapis.com)。 - 确保您的目录项目(或其父级文件夹或组织)在目录位置具有有效的 BigQuery 企业 Plus 版
QUERY预留分配。 - 按照为 SAP Business Data Cloud 设置跨云连接中的说明,在 Google Cloud 项目中设置 BigQuery BigLake Delta Sharing 目录连接。
- 按照查询 SAP 数据中的说明,检索 SAP BDC 租户发布的 Delta Sharing
shareId和架构名称(例如,共享 ID,如customer_v1_he2_100_p8123或salesorder_v1_he2_100_p8124;架构名称,如customer或salesorder)。 - 为每个主账号授予所需的 Identity and Access Management (IAM) 角色:
- CLI 构建主账号 (
uv run cortex-build):针对订阅的 BigLake 目录项目和资源的 BigLake Viewer (roles/biglake.viewer) 和 BigQuery Data Viewer (roles/bigquery.dataViewer)。 - CLI 部署主账号(
uv run cortex-deploy和uv run cortex-build-and-deploy):目录项目上的 BigQuery Resource Viewer (roles/bigquery.resourceViewer),用于验证企业 Plus 版QUERY预留分配;父级文件夹或组织上的 Browser (roles/browser),用于在父级文件夹或组织级别分配企业 Plus 版容量;Dataform 代码库项目上的 Dataform Editor(roles/dataform.editor,或roles/dataform.admin,用于创建代码库);以及目标项目或数据集上的 BigQuery Data Editor (roles/bigquery.dataEditor)(用于检查或使用--create-datasets创建目标数据集)。运行uv run cortex-build-and-deploy需要同时具备 CLI 构建主账号和 CLI 部署主账号角色。 - Dataform 执行服务账号:针对订阅的 BigLake 目录项目和资源的 BigLake Viewer (
roles/biglake.viewer) 和 BigQuery Data Viewer (roles/bigquery.dataViewer);针对可写目标数据集的 BigQuery Data Editor (roles/bigquery.dataEditor);以及针对执行项目的 BigQuery Job User (roles/bigquery.jobUser)。
- CLI 构建主账号 (
配置示例
以下 config/config.yaml 摘录在 data.modules.catalogs 下注册了一个 SAP BDC 目录,并将两个共享架构绑定到下游销售业绩消费数据产品:
buildEnvironment:
buildProjectId: BUILD_PROJECT_ID
data:
bigQueryLocation: europe-west3
namespaces:
- name: cortex
- name: cortex_samples
datasets:
- id: sap_bdc_data_products
projectId: TARGET_PROJECT_ID
datasetId: sap_bdc_data_products
modules:
# 1. Register the SAP BDC BigLake catalog connection (using lakehouse_delta_share type)
catalogs:
- id: sap_bdc_catalog
type: lakehouse_delta_share
enabled: true
bindsNamespaces: [sap_bdc]
connectionSettings:
catalogId: sap_bdc_catalog
projectId: CATALOG_PROJECT_ID
location: europe-west3
shares:
- shareId: CUSTOMER_SHARE_ID
- shareId: SALES_ORDER_SHARE_ID
# Optional: restrict discovered tables with tableSettings or inlineTableSettings:
# inlineTableSettings:
# tables: [customer, salesorder, salesorderitem]
# 2. Reference the catalog schemas in downstream products
products:
- moduleId: sap_bdc_sales_performance
modulePath: cortex_samples.sap_bdc.products.sales_performance
dependencyBindings:
# Bind logical dependencies to catalog schemas (2-part or 3-part format)
sapBdcCustomer: sap_bdc_catalog.CUSTOMER_SHARE_ID.customer
sapBdcSalesOrder: sap_bdc_catalog.SALES_ORDER_SHARE_ID.salesorder
dataTargetId: sap_bdc_data_products
替换以下内容:
BUILD_PROJECT_ID:运行构建作业的 Google Cloud 项目 ID,例如:my-build-project。TARGET_PROJECT_ID:BigQuery 视图的目标 Google Cloud 项目 ID,例如:my-target-project。CATALOG_PROJECT_ID:托管 BigLake 目录的 Google Cloud 项目 ID,例如:my-catalog-project。CUSTOMER_SHARE_ID:SAP BDC 为客户数据公开的 Delta SharingshareId标识符,例如:customer_v1_he2_100_p8123。SALES_ORDER_SHARE_ID:SAP BDC 为销售订单数据公开的 Delta SharingshareId标识符,例如:salesorder_v1_he2_100_p8124。
(可选)您可以在 lakehouse_delta_share 目录条目中添加 tableSettings(相对于 config/ 的 YAML 文件路径)或 inlineTableSettings(tables 或 variants,与 tableSettings 互斥),以将发现范围限制为显式表许可清单。如需查看完整的目录参数架构,请参阅部署配置 (data.modules.catalogs)。
在 dependencyBindings 中将数据产品输入绑定到 BigLake Delta Sharing 目录时,请使用以下架构绑定格式之一:
- 两部分绑定 (
<catalog_id>.<schema_name>):如果<schema_name>在该目录中配置的共享中是唯一的,请使用此较短的格式(例如sap_bdc_catalog.customer或sap_bdc_catalog.salesorder)。 - 三部分绑定 (
<catalog_id>.<share_id>.<schema_name>):当多个已配置的共享中存在相同的<schema_name>时,请使用此显式格式来消除歧义:<catalog_id>与data.modules.catalogs下的目录id匹配。<share_id>与某个已声明的connectionSettings.shares[].shareId条目匹配。<schema_name>与该共享中公开的架构匹配(架构中的各个表在ctx.ref(...)中按名称引用)。
表设置和具体化规则
使用 builder: flat_product(SAP BDC 产品的规范构建器;sap_bdc_product 是已弃用的别名)构建的数据产品在 table_settings.default.yaml(或自定义 table_settings.yaml 和 inlineTableSettings 替换项)中强制执行以下配置规则:
- 显式
view实体化和可选的table或incremental实体化:由于ProductTableItem默认为materializationType: incremental,因此请在table_settings.default.yaml中显式配置materializationType: view,以便对 SAP BDC Delta Sharing 表进行零复制下推。如果需要物理物化,materializationType: table和materializationType: incremental还支持可选的partitionDetails和clusterDetails。 - 平面表键结构:直接在
table_settings.yaml的顶层声明每个输出视图或表。请勿在ecc:、s4:或common:部分键下嵌套条目,否则会导致section_keys_not_allowed预检验证失败。
sales_performance:
materializationType: view
dataformTags: [sap_bdc, sales, consumption]
bigQueryLabels:
- key: line_of_business
value: sales
下游 Dataform 依赖项绑定
在编译 (uv run cortex-build) 期间,Cortex Framework 会将目录绑定解析为完全限定的 BigQuery 联合表引用。使用三参数 ctx.ref(source_project_id, source_dataset_id, "TableName") 签名在 .js 定义中引用绑定的输入:
// Example JS definition referencing SAP BDC inputs
// ___MODULE_CONTEXT___
// ___TABLE_CONFIG___
const publish_config = require("includes/publish_config.js");
const publisher = require("includes/publisher.js");
const moduleConfig = config.product[moduleContext.moduleId];
const customerSource = moduleConfig.sources.sapBdcCustomer;
const salesOrderSource = moduleConfig.sources.sapBdcSalesOrder;
const materializationType = tableConfig.materializationType || "view";
const publishConfig = publish_config.getPublishConfig(
materializationType,
tableConfig,
moduleConfig
);
publisher.publish(moduleContext.moduleId + "_" + tableConfig.tableName, publishConfig).query(
(ctx) => `
SELECT
orders.SalesOrder AS sales_order,
cust.Customer AS customer,
orders.TotalNetAmount AS total_net_amount,
CURRENT_TIMESTAMP() AS bq_loaded_at
FROM ${ctx.ref(
salesOrderSource.projectId,
salesOrderSource.datasetId,
"salesorder"
)} AS orders
LEFT JOIN ${ctx.ref(
customerSource.projectId,
customerSource.datasetId,
"customer"
)} AS cust
ON orders.SoldToParty = cust.Customer
`
);