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

如何让DuckDB Postgres扩展在Postgres 15.3 Aurora集群正常工作?

问题描述

尝试使用DuckDB的Postgres扫描扩展连接Postgres 15.3 Aurora集群,执行代码后SHOW TABLES显示目录无表:

import duckdb
duckdb.execute('INSTALL postgres;')
duckdb.execute('LOAD postgres;')
duckdb.execute('CALL postgres_attach("dbname=**  \
               user=** password=** \
               host=** \
               port=** connect_timeout=** application_name=**\
               ");')
duckdb.sql('USE main')
duckdb.sql('SHOW TABLES').show()

输出结果:

│  name   │
│ varchar │
├─────────┤
│ 0 rows  │

使用单表扫描函数时出现报错:

duckdb.sql('SELECT * FROM postgres_scan("dbname=** \
               host=** \
               user=** password=** port=** ", "**", "**") LIMIT 10;').show()

报错信息:

Failed to execute query "SELECT pg_is_in_recovery(), pg_export_snapshot(), (select count(*) from pg_stat_wal_receiver)": ERROR: Function pg_stat_get_wal_receiver() is currently not supported in Aurora.

解决方法
  • 跳过WAL接收器检查:Aurora不支持pg_stat_get_wal_receiver()函数,而DuckDB的Postgres扩展默认会执行相关查询。在连接参数中添加postgres_scanner_enable_wal_receiver_check=false即可禁用该检查。
    示例修改后的postgres_attach调用:
    CALL postgres_attach("dbname=** user=** password=** host=** port=** connect_timeout=** application_name=** postgres_scanner_enable_wal_receiver_check=false");
    
  • 指定目标Schema:如果Postgres中的表不在默认public模式下,需在连接参数中明确指定schema,或Attach后切换到对应模式:
    -- 方式1:Attach时指定Schema
    CALL postgres_attach("dbname=** ... schema=your_target_schema");
    -- 方式2:Attach后切换Schema
    duckdb.sql('USE your_target_schema')
    
  • 升级DuckDB版本:当前使用的是0.6.1版本的文档,新版本的Postgres扫描扩展已修复部分Aurora兼容性问题,建议升级到最新稳定版后重试。
  • 单表扫描时添加参数:使用postgres_scan函数时,同样需要在连接字符串中加入禁用检查的参数:
    SELECT * FROM postgres_scan("dbname=** host=** user=** password=** port=** postgres_scanner_enable_wal_receiver_check=false", "your_schema", "your_table") LIMIT 10;
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 07:46:27