使用 Lakehouse 运行时目录将 SAP Business Data Cloud 数据产品与 Cortex Framework 集成并同步。
本文档介绍了如何使用 Lakehouse 运行时目录集成将 Cortex Framework 连接到 SAP Business Data Cloud。
通过将 Google Cloud SAP Delta Sharing 与 BigQuery Lakehouse 运行时目录联合连接相结合,Cortex Framework 可以直接在 BigQuery 中查询 SAP BDC 内管理的任何数据产品,而无需复制开销,并可在自定义下游分析数据产品中引用这些数据产品。此集成的关键组件包括:
- 联合查询:SAP BDC 中发布的数据产品通过安全的 Delta Sharing 端点公开。BigQuery 使用 Google Cloud Lakehouse 运行时目录连接将查询联合到这些端点。
- 目录注册:在 Cortex Framework 中,您可以使用
config/config.yaml中data.modules.catalogs下的delta_share类型模块注册 SAP BDC 目录。 - Google Cloud Cortex Framework 数据产品绑定:下游自定义数据产品通过将其输入依赖项绑定到特定 Delta Sharing 共享和表 ID(格式为
{catalog_id}.{share_id}.{table_name})来引用 BDC 目录表。
SAP BDC 的前提条件
在 Cortex Framework 中配置连接之前,您必须在 Google Cloud 和 SAP 中完成以下步骤:
- 配置 Google Cloud Lakehouse 运行时目录:在 Google Cloud 项目中设置 BigQuery Lakehouse 运行时目录连接,利用 Google Cloud Delta Sharing for SAP Business Data Cloud。
- 检索共享 ID:查找并列出已连接的 SAP BDC 租户发布的 Delta Sharing
shareId值(例如customer_v1_he2_100_p8123或salesorder_v1_he2_100_p8124)。
配置示例
以下示例配置注册了一个 SAP BDC 目录,并使用其共享来计算自定义销售业绩数据产品:
buildEnvironment:
buildProjectId: YOUR_BUILD_PROJECT_ID
data:
bigQueryLocation: europe-west3
namespaces:
- name: cortex
path: ../src/data_modules/cortex
- name: cortex_samples
path: ../src/data_modules/cortex_samples
datasets:
- id: sap_bdc_data_products
projectId: YOUR_TARGET_PROJECT_ID
datasetId: sap_bdc_data_products
modules:
# 1. Register the SAP BDC Lakehouse runtime 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: YOUR_CATALOG_PROJECT_ID
location: europe-west3
shares:
- shareId: customer_v1_he2_100_p8123
- shareId: salesorder_v1_he2_100_p8124
# 2. Reference the catalog shares in downstream products
products:
- moduleId: sap_bdc_sales_performance
modulePath: cortex_samples.sap_bdc.products.sales_performance
dependencyBindings:
# Bind logical dependencies directly to the catalog shares and tables
sapBdcCustomer: sap_bdc_catalog.customer_v1_he2_100_p8123.customer
sapBdcSalesOrder: sap_bdc_catalog.salesorder_v1_he2_100_p8124.salesorder
dataTargetId: sap_bdc_data_products
如需了解参数参考信息,请参阅数据目录模块类型的部署配置部分。
当自定义数据产品依赖于 Lakehouse 运行时目录表时,请使用目录路径语法在 config/config.yaml 中配置其输入依赖项:
dependencyBindings:
{logical_input_name}: {catalog_id}.{share_id}.{table_name}
其中:
{catalog_id}匹配data.modules.catalogs下的目录id属性。{share_id}与声明的某个目录shareId字符串匹配。{table_name}与相应共享中公开的物理表名称相匹配。
下游 Dataform 依赖项绑定
在编译 (cortex-build) 期间,Cortex Framework 会读取目录元数据,并将依赖项绑定自动转换为完全限定的 BigQuery 联邦表名称。
在自定义数据产品定义(例如 .js 或 .sqlx 文件)中,引用已规范化的 SAP BDC 源:
// Example JS definition referencing SAP BDC inputs
const moduleConfig = config.product[moduleContext.moduleId];
const customerSource = moduleConfig.sources.sapBdcCustomer;
const salesOrderSource = moduleConfig.sources.sapBdcSalesOrder;
publish("custom_sales_performance", {
type: "table",
}).query(
(ctx) => `
SELECT
cust.customer_id,
orders.sales_order_id,
orders.amount
FROM ${ctx.ref(customerSource.datasetId, customerSource.tableName)} AS cust
JOIN ${ctx.ref(salesOrderSource.datasetId, salesOrderSource.tableName)} AS orders
ON cust.customer_id = orders.customer_id
`
);