You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启用Unity Catalog的Databricks工作区发布特征到Cosmos DB报Catalog未找到

问题现象

我们参考官方文档尝试用Cosmos DB搭建Databricks在线特征存储时遇到以下问题:

  • 在未启用Unity Catalog(UC)的Databricks工作区中,执行fs.publish_table可正常创建Cosmos DB的数据库和容器,并完成特征发布。
  • 在启用UC的工作区中执行相同代码,抛出AnalysisException: Catalog 'cosmoscatalog' not found错误。
  • 补充:若先在非UC工作区创建好Cosmos DB的容器/数据库,启用UC的工作区可以通过fs.publish_table执行更新操作(mode='merge'),但无法新建资源。

使用的代码示例:

from databricks.feature_store.online_store_spec import AzureCosmosDBSpec
from databricks.feature_store.client import FeatureStoreClient

fs = FeatureStoreClient()

account_uri = "https://online-feature-store.documents.azure.com:443/"

# Specify the online store.
online_store_spec = AzureCosmosDBSpec(
  account_uri=account_uri,
  write_secret_prefix="secret/write-cosmos",
  read_secret_prefix="secret/read-cosmos",
  database_name="online_feature_store_example",
  container_name="feature_store_online_wine_features"
)

# Push the feature table to online store.
fs.publish_table("online_feature_store_example.wine_static_features", online_store_spec, mode='merge')
原因分析

启用Unity Catalog后,Databricks Feature Store在发布特征到Cosmos DB这类外部在线存储时,默认会尝试将外部表元数据关联到名为cosmoscatalog的内置Catalog。但该Catalog在部分UC配置环境中未被自动注册,或者当前执行用户无访问权限,导致创建新Cosmos资源时元数据写入失败;而更新操作无需新建元数据(已有非UC环境创建的资源关联),因此可以正常执行。

解决方案

1. 显式指定UC Catalog和Schema存储外部表元数据

在调用fs.publish_table时,通过target_catalog和target_schema参数指定已存在的UC Catalog(如默认的hive_metastore或自定义创建的Catalog)及Schema,避免默认使用不存在的cosmoscatalog:

修改后的代码示例:

# Push the feature table to online store with explicit UC catalog/schema
fs.publish_table(
  "online_feature_store_example.wine_static_features",
  online_store_spec,
  mode='merge',
  target_catalog="hive_metastore",  # 替换为你的UC Catalog名称
  target_schema="feature_store_schemas"  # 替换为已存在的Schema名称
)

2. 验证权限配置

  • 确认write_secret_prefix对应的Databricks密钥包含Cosmos DB账户的写入权限(需支持创建数据库、容器)。
  • 确保执行代码的用户对指定的target_catalog和target_schema拥有USAGE权限,以及CREATE TABLE权限,用于创建外部表元数据。

3. 临时 workaround:预创建Cosmos资源

若上述配置暂时无法生效,可先在非UC工作区执行fs.publish_table创建好Cosmos DB的数据库和容器,再切换到UC工作区执行mode='merge'的发布操作完成特征更新,该方式已验证可行。

内容的提问来源于stack exchange,提问作者Samlex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 12:10:54