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

Feast 0.24.1配置PostgreSQL离线存储时AssertionError问题求助

解决Feast使用PostgreSQL离线存储时的AssertionError问题

错误原因

你遇到的AssertionError: assert isinstance(fv.batch_source, PostgreSQLSource),核心原因是特征视图(Feature View)配置的数据源不是PostgreSQLSource类型——即便你在feature_store.yaml里指定了离线存储为PostgreSQL,特征定义里的数据源还是默认的文件源(或其他非PostgreSQL源),导致离线存储无法识别处理。

修复步骤

1. 修改特征定义文件

找到你的特征仓库里的特征定义文件(比如feature_repo/features.py),将原来的文件数据源替换为PostgreSQL数据源:

首先导入PostgreSQLSource类:

from feast.infra.offline_stores.contrib.postgres_offline_store.postgres import PostgreSQLSource

然后替换原有的数据源配置,比如把默认的FileSource改成PostgreSQLSource:

# 替换前的错误配置(默认文件源)
driver_hourly_stats_source = FileSource(
    path=os.path.join(os.path.dirname(__file__), "data", "driver_stats.parquet"),
    event_timestamp_column="event_timestamp",
    created_timestamp_column="created",
)

# 替换后的正确配置(PostgreSQL源)
driver_hourly_stats_source = PostgreSQLSource(
    table_ref="feastschema.driver_stats",  # 替换为你PostgreSQL中的目标表名(需包含schema)
    event_timestamp_column="event_timestamp",
    created_timestamp_column="created",
)

2. 重新部署特征仓库

在特征仓库目录下执行命令,更新Feast注册表:

feast apply

3. 验证配置一致性

确保PostgreSQLSource指向的表在你的feastdb数据库中存在,且表结构包含event_timestamp和created字段;同时数据源的schema、库名要和feature_store.yaml中offline_store的配置保持一致。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 15:05:22