升级到 7.1 版

本指南列出了将现有 Google Cloud Cortex Framework 7.0.x 版部署升级到 7.1.0 版时需要执行的版本特定更改和迁移操作。请按照这些说明以及升级 Cortex Framework 中的标准工作流进行操作。您还可以运行 /upgrade-cortex 智能体技能,以自动检查和更新配置文件。

Python 仍为 3.13 (>=3.13,<3.14)。如需了解计划在 8.0 版中移除的已弃用项,请参阅 Cortex Framework 弃用项。

您可以使用下表跳转到适用于您的部署的部分:

如果您的部署使用… 查看
任何 7.0.x 版设置 配置和 CLI 变更
SAP ERP 数据产品 破坏性 SAP 列更改和完全刷新以及行为更改和孤立对象
自定义 tableSettings 替换项 自定义 table_settings.yaml 更新
自定义模块或 Python 构建器 迁移自定义数据产品和 Python 构建器

配置和 CLI 变更

在构建之前,请在第 2 步:更新配置、自定义设置和扩展程序期间应用这些更新。

命名空间发现

  • 内置命名空间:省略内置 data.namespaces 条目(cortex、cortex_samples、cortex_v6_compatibility)上的 path,例如 - name: cortex。
  • 许可名单行为:data.namespaces 现在是严格的许可名单(namespaces: [] 启用零命名空间,namespaces: null 无法通过验证)。列出您启用的模块引用的每个内置和本地自定义命名空间,或省略 data.namespaces 以仅自动发现已安装的软件包。

数据质量断言

  • 默认启用 (data.assertionsEnabled: true):共享 Google Cloud项目时,为每个部署设置唯一的 data.defaultAssertionDataset(否则默认 dataform_assertions 数据集可能会在部署之间发生冲突),并在 CI/CD 中将 --create-datasets 传递给 uv run cortex-deploy。如需停用,请设置 data.assertionsEnabled: false。
  • 严重程度标记:同时配置 data.assertionSeverities 和 data.defaultAssertionSeverity,或同时省略。

目标值和目录设置

  • 已移除 type: generic 目标:移除 type: generic 条目或将其替换为 type: git(请注意,type: git 需要使用 targetSettings.authorEmail、全局 git config user.email 或同时使用 GIT_AUTHOR_EMAIL 和 GIT_COMMITTER_EMAIL 的提交电子邮件)。
  • 整个细分 ignoredPaths 匹配:在 type: dataform 目标上,targetSettings.ignoredPaths(默认 ["definitions/custom"])现在匹配整个路径段,而不是前缀。将非托管文件移至 definitions/custom/ 下,或将 definitions/custom_* 等路径添加到 ignoredPaths,这样 uv run cortex-deploy 就不会删除这些文件。
  • 目录 tableSettings 许可清单:更新所有目录 tableSettings 文件(tables:/variants:),以便列出每个必需的源表。

CLI 变更

版本 7.0.x 版本 7.1
uv run cortex-build --create-datasets 将 --create-datasets(以及可选的 -y/--yes)传递给 uv run cortex-deploy 或 uv run cortex-build-and-deploy。
uv run cortex-deploy --assertions 将 --assertions 传递给 uv run cortex-build 或 uv run cortex-build-and-deploy。
uv run cortex-kc-sync和--data-modules-root-directory之间 使用 uv run cortex-create-kc-data-products 并在 data.namespaces 中声明命名空间。
uv run cortex-demo(仅限 SAP 的默认值;snake_case 标志) 默认值为 --sources all(传递 --sources sap 可保留 7.0.x 范围),带有短划线大小写标志;请参阅 uv run cortex-demo。

自定义 table_settings.yaml 更新

遵循升级过程中的自定义 table_settings.yaml 行为,并应用以下 7.1 版更新:

  • 数据产品:将复制的文件缩减为显式替换,尤其是 sales_document_flow 上的任何过时 materializationType: incremental 替换(请参阅行为变更和孤立对象)和未更改的 dataformTags(例如,billing_document_headers 和 billing_document_items 从 monthly 更改为 hourly)。
  • 数据基础:将自定义 SAP 基础文件与版本 7.1 table_settings.default.yaml 进行比较,以保留添加的 ECC 表(faglflext、glt0)和默认断言(makt、vbak)。
  • 时间分区:将已废弃的 partitionType: DATE | DATETIME | TIMESTAMP 替换为 partitionType: time 和 dataType: DATE | DATETIME | TIMESTAMP。

破坏性 SAP 列更改和完全刷新

7.1 版将 SAP 数据产品列后缀与确切的 SAP 数据字典 (DDIC) 字段名称对齐,并移除了 23 个增量 SAP 产品表中的非核心 SAP IS-Fashion (*_fsh_*) 插件列。

SAP 列重命名和移除参考

展开即可查看 23 个表的 SAP 列重命名和移除映射

数据产品 表 SAP 版本 7.0.x 版列 版本 7.1 列或状态
accounts_payable accounts_payable S/4HANA bus_transac_type_bttype
condition_contract_coco_number
inventory_movement_category_invoice_mov_categ
service_document_type_service_document_type
service_document_service_document_id
service_document_item_service_document_item_id
partner_service_document_type_pservice_document_type
partner_service_document_pservice_document_id
partner_service_document_item_pservice_document_item_id
company_code_for_budget_account_bdgt_account_company_code
business_transaction_category_bttype
condition_contract_coco_num
inventory_movement_category_inv_mov_categ
service_document_type_service_doc_type
service_document_service_doc_id
service_document_item_service_doc_item_id
partner_service_document_type_pservice_doc_type
partner_service_document_pservice_doc_id
partner_service_document_item_pservice_doc_item_id
company_code_for_budget_account_bdgt_account_cocode
accounts_receivable accounts_receivable S/4HANA 与上一行中的 accounts_payable 相同的 10 列 与上一行中的 accounts_payable 相同的 10 个重命名列
addresses addresses ECC、S/4HANA flag_x400flagcomm8 flag_x400_flagcomm8
bill_of_materials bill_of_materials_items ECC、S/4HANA deviation_values_fsh_vmkz、quantity_distribution_profile_fsh_pgqr、quantity_distribution_profile_reference_fsh_pgqrrf、critical_component_fsh_critical_comp、critical_level_fsh_critical_level 已移除(IS-Fashion 插件)
billing_documents billing_document_items ECC、S/4HANA season_year_fsh_season_year、season_fsh_season、collection_fsh_collection、theme_fsh_theme 已移除(IS-Fashion 插件)
customers customers ECC、S/4HANA name_of_representative_j_1_kfrepre
type_of_business_j_1_kftbus
type_of_industry_j_1_kftind
name_of_representative_j_1kfrepre
type_of_business_j_1kftbus
type_of_industry_j_1kftind
delivery_documents delivery_document_headers ECC number_category_1_rpfaess
number_category_2_rpkist
number_category_3_rpcont
number_category_4_rpsonst
loading_sequence_number_rpflgnr
number_category_1_bev1_rpfaess
number_category_2_bev1_rpkist
number_category_3_bev1_rpcont
number_category_4_bev1_rpsonst
loading_sequence_number_bev1_rpflgnr
delivery_documents delivery_document_headers S/4HANA header_customer_reserve_status1_suvk01 至 5_suvk05
item_customer_reserve_status1_suvs01 至 5_suvs05
header_customer_reserve_status1_uvk01 至 5_uvk05
item_customer_reserve_status1_uvs01 至 5_uvs05
delivery_documents delivery_document_items ECC、S/4HANA cfop_code_and_extension_j_1_bcfop
tax_law_icms_j_1_btaxlw1
tax_law_ipi_j_1_btaxlw2
iss_tax_law_j_1_btaxlw3
cofins_tax_law_j_1_btaxlw4
pis_tax_law_j_1_btaxlw5
sd_tax_code_j_1_btxsdc
cfop_code_and_extension_j_1bcfop
tax_law_icms_j_1btaxlw1
tax_law_ipi_j_1btaxlw2
iss_tax_law_j_1btaxlw3
cofins_tax_law_j_1btaxlw4
pis_tax_law_j_1btaxlw5
sd_tax_code_j_1btxsdc
inventory_and_special_stocks sales_order_stock ECC season_year_fsh_season_year、season_fsh_season、collection_fsh_collection、theme_fsh_theme、allocated_stock_quantity_fsh_salloc_qty 已移除(IS-Fashion 插件)
inventory_and_special_stocks special_stocks_from_vendor ECC 与 sales_order_stock 相同的 5 个 *_fsh_* 列 已移除(IS-Fashion 插件)
inventory_and_special_stocks special_stocks_with_customer ECC 与 sales_order_stock 相同的 5 个 *_fsh_* 列 已移除(IS-Fashion 插件)
production_orders production_order_header ECC、S/4HANA master_production_order_fsh_mprod_ord 已移除(IS-Fashion 插件)
production_orders production_order_item ECC、S/4HANA season_year_fsh_season_year、season_fsh_season、collection_fsh_collection、theme_fsh_theme、allocated_stock_quantity_fsh_salloc_qty 已移除(IS-Fashion 插件)
purchasing_documents purchasing_document_account_assignments S/4HANA service_document_type_service_document_type
service_document_service_document_id
service_document_item_service_document_item_id
service_document_type_service_doc_type
service_document_service_doc_id
service_document_item_service_doc_item_id
purchasing_documents purchasing_document_headers ECC、S/4HANA discount_days1_zbd1_t、discount_days2_zbd2_t、discount_days3_zbd3_t
cash_discount_percentage1_zbd1_p、cash_discount_percentage2_zbd2_p
logical_system_logsy
discount_days1_zbd1t、discount_days2_zbd2t、discount_days3_zbd3t
cash_discount_percentage1_zbd1p、cash_discount_percentage2_zbd2p
logical_system_logsys
purchasing_documents purchasing_document_items ECC、S/4HANA inflation_index_j_1_aindxp
inflation_index_date_j_1_aidatep
inflation_index_j_1aindxp
inflation_index_date_j_1aidatep
purchasing_documents purchasing_document_types ECC 9 个 *_fsh_* 列:vas_active_flag_fsh_vas_act、determination_procedure_fsh_vas_kalsm、vas_deletion_criteria_fsh_vas_del、vas_determination_date_fsh_vas_detdt、excl_return_items_fsh_excl_return、determination_procedure_fsh_var_kalsm、determination_procedure_fsh_dpr_detpro、generic_material_creation_fsh_po_idoc、auto_distribution_fsh_auto_dc 已移除(IS-Fashion 插件)
purchasing_documents purchasing_document_types S/4HANA 相同的 9 个 ECC *_fsh_* 列,外加 vas_quantity_correlation_fsh_vas_corr 和 variants_optional_fsh_vm_act(共 11 个) 已移除(IS-Fashion 插件)
purchasing_documents purchasing_document_vendor_confirmations ECC、S/4HANA allocated_stock_quantity_fsh_salloc_qty 已移除(IS-Fashion 插件)
purchasing_documents purchasing_documents_history ECC、S/4HANA logical_system_logsy(ECC、S/4HANA)
quantity_quantity_diff (S/4HANA)
season_year_fsh_season_year、season_fsh_season、 collection_fsh_collection、theme_fsh_theme(ECC、S/4HANA)
logical_system_logsys(ECC、S/4HANA)
quantity_qty_diff (S/4HANA)
已移除(IS-Fashion 插件)
universal_journal universal_journal_entry_line_items S/4HANA business_transaction_type_bttype
custom_business_transaction_type_not_used_yet_cbttype
account_assignment_type_accasty
partner_account_assignment_type_paccasty
business_transaction_category_bttype
business_transaction_type_cbttype
object_type_accasty
partner_object_type_paccasty
vendor_invoices vendor_invoice_headers ECC、S/4HANA logical_system_logsy logical_system_logsys(还添加了不间断 company_code_bukrs)
vendor_invoices vendor_invoice_items ECC、S/4HANA season_year_fsh_season_year、season_fsh_season、fashion_collection_fsh_collection、fashion_theme_fsh_theme Removed (IS-Fashion add-on; non-breaking company_code_bukrs also added)
vendors vendors ECC、S/4HANA name_of_representative_j_1_kfrepre
type_of_business_j_1_kftbus
type_of_industry_j_1_kftind
name_of_representative_j_1kfrepre
type_of_business_j_1kftbus
type_of_industry_j_1kftind

用于一次性完全刷新的其他表

在适用的情况下,对以下增量表运行一次性定向全面刷新 (Run a targeted full refresh):

  • 在首次运行 7.1 版增量运行之前或当天需要执行的操作 (S/4HANA):material_documents (cortex.sap.products.materials_movement) 添加了 13 个 MATDOC 库存列,并使用 material_document_record_type 扩展了 uniqueKey。
  • 在过账非两位小数货币(TCURX 伸缩)时为必填项:asset_annual_cumulative_balances (S/4HANA) 以及 vendor_open_items、vendor_cleared_items、customer_open_items 和 customer_cleared_items (ECC)。(accounts_payable、accounts_receivable 和 purchasing_document_headers 已包含在上面的 23 个表的列表中。)
  • 如果启用 sales_performance SAP ERP 示例,则必须执行以下操作: sales_performance(cortex_samples.sap.products.sales_performance;在 customers 之后刷新)添加了 v7.1 列,例如由新 signed_net_value_bounds 断言验证的 signed_net_value_in_document_currency(请参阅销售业绩数据分析)。

对这些增量表运行一次性全面刷新,以清除版本 7.0.x 联接和可为 null 的 LEFT JOIN 唯一键缺陷中的旧版重复项:

  • 客户、供应商和地址联接:business_partner_addresses、business_partner_bank_details 和下游 supplier_spend_analysis(在 vendors 之后刷新)。
  • uniqueKey(ECC、S/4HANA):vendor_invoice_account_assignments 和 countries。
  • 受保护的可为 null 的 LEFT JOIN 唯一键 (ECC, S/4HANA):asset_transaction_types、cost_elements、cost_centers、profit_centers、currency_codes、set_headers、depreciation_terms、fixed_assets_master、general_ledger_accounts、country_tax_regions、languages、ledger_master、material_cross_plant_batches、material_plant_batches、material_batch_stocks、material_plants、material_movement_types、flattened_product_hierarchies、project_structure、distribution_channels、divisions、sales_organizations 和 units_of_measurement。
  • 受保护的可为 null 的 LEFT JOIN 唯一键(仅限 ECC):special_stocks_with_vendor。
  • 受保护的可为 null 的 LEFT JOIN 唯一键(仅限 S/4HANA):financial_hierarchy_nodes 和 group_journal_entries(还会添加聚簇)。

行为变更和孤立对象

  • sales_document_flow 具体化:ECC 和 S/4HANA 上的默认 materializationType 从 incremental 更改为 table,以便未开单的出库交货保持可见(增加行数)。在编译之前,请移除所有过时的 materializationType: incremental 替换,因为在没有 uniqueKeys 的情况下,incremental 模型会因故障关闭而导致编译失败。--full-refresh 为必填项。
  • 孤立的 S/4HANA 表:materials_by_storage_location 已从 cortex.sap.products.materials 移至仅限 ECC 的 cortex.sap.products.inventory_and_special_stocks。在 S/4HANA 上,确认没有下游使用方查询旧版 PRODUCT_DATASET.materials_by_storage_location 表(以及未使用的 mard、mbew、mbewh 或 t001l 基础表,前提是没有其他已启用的 S/4HANA 产品引用它们)后,请将其删除。
  • 对现有数据的断言:在您完成一次性完全刷新之前,默认断言可能会在升级前的重复行上失败。严重级别标记会发出 severity_LEVEL,而屏蔽行为是按规则 (blocking: true) 设置的。

迁移自定义数据产品和 Python 构建器

如果您维护自定义模块或 Python 构建器,请在构建之前应用以下更新(如需查看完整参考,请参阅可扩展性指南)。

自定义 YAML 和 JavaScript 数据产品

  • 使用 publisher.publish() / publisher.operate():将裸 publish(...) 和 operate(...) 调用替换为 const publisher = require("includes/publisher.js");,以便运行阻塞断言和行级/列级安全钩子。
  • 更新 incremental.getFilter() 调用:将选项对象({ targetColumn: "..." } 或 { timestampColumn: "..." })或已知来源类型简写("sap"、"sfdc" 或 "salesforce")作为第三个参数传递;其他字符串现在会抛出错误。
  • 明确声明断言:将 7.0.x 版隐式键断言替换为 table_settings.default.yaml 中的 assertions.standardRules(请参阅数据质量断言)。
  • 清理已废弃的键和构建器别名:从 manifest.yaml 中移除 type:,并从 config/config.yaml 中移除 moduleType:。替换已弃用的别名(generic_product、composite_product、generic_composite_product、sap_bdc_product → flat_product;sfdc → sfdc_foundation)。请注意,flat_product 默认为 incremental(而旧版 generic_product/composite_product 默认为 table),因此请明确设置 materializationType 或提供 uniqueKeys。

自定义 Python 构建器

  • 从 common.sdk 导入:将 common.builders.*、common.schemas.* 和已移除的 common.registry 导入内容替换为 common.sdk。
  • 使用具体子类:直接子类化 FlatProductBuilder 或 FoundationBuilder(而非 ProductBuilder[DataProductModuleConfig]),并在 build() 中接受 (self, node, ctx)。
  • 为程序化构建器设置 table_settings_schema = None:默认情况下,FlatProductBuilder 的子类构建器需要 table_settings 文件;如果您的构建器在没有该文件的情况下生成 SQL,请设置 table_settings_schema = None。
  • 重新定位构建器:将已弃用的蓝图本地 ./builder.py 模块移至 NAMESPACE/builders/ 中,并在 manifest.yaml 中引用 plugin_id,然后移除命名空间树中的 __init__.py 文件。

后续步骤