rdf_fdw
概览
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 8760 | rdf_fdw | 否 | 是 | 否 | 是 | 否 | 否 | sparql |
Package 3.0.0; SQL extension 3.0. Upgrades from 2.x require the upstream rdfnode index and dependent-object migration; REINDEX alone is insufficient.
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 3.0 | 1817161514 | rdf_fdw | - |
| RPM | PIGSTY | 3.0.0 | 1817161514 | rdf_fdw_$v | - |
| DEB | PIGSTY | 3.0.0 | 1817161514 | postgresql-$v-rdf-fdw | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 3.0.0 el8.x86_64.pg18 : rdf_fdw_18 rdf_fdw_18-3.0.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.0.0 el8.x86_64.pg17 : rdf_fdw_17 rdf_fdw_17-3.0.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.0.0 el8.x86_64.pg16 : rdf_fdw_16 rdf_fdw_16-3.0.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.0.0 el8.x86_64.pg15 : rdf_fdw_15 rdf_fdw_15-3.0.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 3.0.0 el8.x86_64.pg14 : rdf_fdw_14 rdf_fdw_14-3.0.0-1PGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 3.0.0 el8.aarch64.pg18 : rdf_fdw_18 rdf_fdw_18-3.0.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.0.0 el8.aarch64.pg17 : rdf_fdw_17 rdf_fdw_17-3.0.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.0.0 el8.aarch64.pg16 : rdf_fdw_16 rdf_fdw_16-3.0.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.0.0 el8.aarch64.pg15 : rdf_fdw_15 rdf_fdw_15-3.0.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 3.0.0 el8.aarch64.pg14 : rdf_fdw_14 rdf_fdw_14-3.0.0-1PGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 3.0.0 el9.x86_64.pg18 : rdf_fdw_18 rdf_fdw_18-3.0.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.0.0 el9.x86_64.pg17 : rdf_fdw_17 rdf_fdw_17-3.0.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.0.0 el9.x86_64.pg16 : rdf_fdw_16 rdf_fdw_16-3.0.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.0.0 el9.x86_64.pg15 : rdf_fdw_15 rdf_fdw_15-3.0.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 3.0.0 el9.x86_64.pg14 : rdf_fdw_14 rdf_fdw_14-3.0.0-1PGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 3.0.0 el9.aarch64.pg18 : rdf_fdw_18 rdf_fdw_18-3.0.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.0.0 el9.aarch64.pg17 : rdf_fdw_17 rdf_fdw_17-3.0.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.0.0 el9.aarch64.pg16 : rdf_fdw_16 rdf_fdw_16-3.0.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.0.0 el9.aarch64.pg15 : rdf_fdw_15 rdf_fdw_15-3.0.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 3.0.0 el9.aarch64.pg14 : rdf_fdw_14 rdf_fdw_14-3.0.0-1PGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY 3.0.0 el10.x86_64.pg18 : rdf_fdw_18 rdf_fdw_18-3.0.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.0.0 el10.x86_64.pg17 : rdf_fdw_17 rdf_fdw_17-3.0.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.0.0 el10.x86_64.pg16 : rdf_fdw_16 rdf_fdw_16-3.0.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.0.0 el10.x86_64.pg15 : rdf_fdw_15 rdf_fdw_15-3.0.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 3.0.0 el10.x86_64.pg14 : rdf_fdw_14 rdf_fdw_14-3.0.0-1PGSTY.el10.x86_64.rpm
|
| el10.aarch64 | PIGSTY 3.0.0 el10.aarch64.pg18 : rdf_fdw_18 rdf_fdw_18-3.0.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.0.0 el10.aarch64.pg17 : rdf_fdw_17 rdf_fdw_17-3.0.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.0.0 el10.aarch64.pg16 : rdf_fdw_16 rdf_fdw_16-3.0.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.0.0 el10.aarch64.pg15 : rdf_fdw_15 rdf_fdw_15-3.0.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 3.0.0 el10.aarch64.pg14 : rdf_fdw_14 rdf_fdw_14-3.0.0-1PGSTY.el10.aarch64.rpm
|
| d12.x86_64 | PIGSTY 3.0.0 d12.x86_64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.0.0 d12.x86_64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.0.0 d12.x86_64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.0.0 d12.x86_64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 3.0.0 d12.x86_64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 3.0.0 d12.aarch64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.0.0 d12.aarch64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.0.0 d12.aarch64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.0.0 d12.aarch64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 3.0.0 d12.aarch64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY 3.0.0 d13.x86_64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~trixie_amd64.deb
| PIGSTY 3.0.0 d13.x86_64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~trixie_amd64.deb
| PIGSTY 3.0.0 d13.x86_64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~trixie_amd64.deb
| PIGSTY 3.0.0 d13.x86_64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~trixie_amd64.deb
| PIGSTY 3.0.0 d13.x86_64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~trixie_amd64.deb
|
| d13.aarch64 | PIGSTY 3.0.0 d13.aarch64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~trixie_arm64.deb
| PIGSTY 3.0.0 d13.aarch64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~trixie_arm64.deb
| PIGSTY 3.0.0 d13.aarch64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~trixie_arm64.deb
| PIGSTY 3.0.0 d13.aarch64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~trixie_arm64.deb
| PIGSTY 3.0.0 d13.aarch64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~trixie_arm64.deb
|
| u22.x86_64 | PIGSTY 3.0.0 u22.x86_64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~jammy_amd64.deb
| PIGSTY 3.0.0 u22.x86_64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~jammy_amd64.deb
| PIGSTY 3.0.0 u22.x86_64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~jammy_amd64.deb
| PIGSTY 3.0.0 u22.x86_64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~jammy_amd64.deb
| PIGSTY 3.0.0 u22.x86_64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 3.0.0 u22.aarch64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~jammy_arm64.deb
| PIGSTY 3.0.0 u22.aarch64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~jammy_arm64.deb
| PIGSTY 3.0.0 u22.aarch64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~jammy_arm64.deb
| PIGSTY 3.0.0 u22.aarch64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~jammy_arm64.deb
| PIGSTY 3.0.0 u22.aarch64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 3.0.0 u24.x86_64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~noble_amd64.deb
| PIGSTY 3.0.0 u24.x86_64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~noble_amd64.deb
| PIGSTY 3.0.0 u24.x86_64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~noble_amd64.deb
| PIGSTY 3.0.0 u24.x86_64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~noble_amd64.deb
| PIGSTY 3.0.0 u24.x86_64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 3.0.0 u24.aarch64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~noble_arm64.deb
| PIGSTY 3.0.0 u24.aarch64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~noble_arm64.deb
| PIGSTY 3.0.0 u24.aarch64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~noble_arm64.deb
| PIGSTY 3.0.0 u24.aarch64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~noble_arm64.deb
| PIGSTY 3.0.0 u24.aarch64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~noble_arm64.deb
|
| u26.x86_64 | PIGSTY 3.0.0 u26.x86_64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~resolute_amd64.deb
| PIGSTY 3.0.0 u26.x86_64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~resolute_amd64.deb
| PIGSTY 3.0.0 u26.x86_64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~resolute_amd64.deb
| PIGSTY 3.0.0 u26.x86_64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~resolute_amd64.deb
| PIGSTY 3.0.0 u26.x86_64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~resolute_amd64.deb
|
| u26.aarch64 | PIGSTY 3.0.0 u26.aarch64.pg18 : postgresql-18-rdf-fdw postgresql-18-rdf-fdw_3.0.0-1PGSTY~resolute_arm64.deb
| PIGSTY 3.0.0 u26.aarch64.pg17 : postgresql-17-rdf-fdw postgresql-17-rdf-fdw_3.0.0-1PGSTY~resolute_arm64.deb
| PIGSTY 3.0.0 u26.aarch64.pg16 : postgresql-16-rdf-fdw postgresql-16-rdf-fdw_3.0.0-1PGSTY~resolute_arm64.deb
| PIGSTY 3.0.0 u26.aarch64.pg15 : postgresql-15-rdf-fdw postgresql-15-rdf-fdw_3.0.0-1PGSTY~resolute_arm64.deb
| PIGSTY 3.0.0 u26.aarch64.pg14 : postgresql-14-rdf-fdw postgresql-14-rdf-fdw_3.0.0-1PGSTY~resolute_arm64.deb
|
构建
您可以使用 pig build 命令构建 rdf_fdw 扩展的 RPM / DEB 包:
安装
您可以直接安装 rdf_fdw 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
使用 pig 或者是 apt/yum/dnf 安装扩展:
创建扩展:
用法
来源:
rdf_fdw 是通过 SPARQL endpoint 查询 RDF triplestore 的 PostgreSQL foreign data wrapper。它把 SPARQL 结果变量暴露为外部表列,支持常见 SQL 子句下推,提供用于 RDF term 的原生 rdfnode 类型,实现了多种 SPARQL 1.1 辅助函数,并可通过可写外部表执行 SPARQL INSERT、UPDATE 和 DELETE。
发行包 3.0.0 对应 SQL 扩展版本 3.0。本次修复 RDF 比较、算术与下推正确性。GROUP BY、DISTINCT、UNION 和唯一约束按 RDF 项的书写形式区分;sparql.uri() 现在返回 rdfnode,赋值到文本列时需要显式转换。部分无法安全下推的条件改为本地执行。
创建扩展
从 2.x 升级前,先保存并删除 rdfnode 列上的索引,以及对其排序、分组或去重的依赖视图、物化视图或 SQL 函数体函数。升级后重建这些对象;仅执行 REINDEX 不够。新安装与已做好准备的升级应分别选择适用命令:
注册 SPARQL Endpoint
常用 server options:
endpoint:SPARQL endpoint URL,必需。batch_size:每批 SPARQL UPDATE 的行数。enable_pushdown:启用 SQL 到 SPARQL 的下推。format:期望的 SPARQL 结果 MIME 类型。http_proxy:代理 URL;代理凭据应放在USER MAPPING。connect_timeout:连接超时。request_timeout:完整 HTTP 请求超时。max_response_size:最大响应体字节数;0表示不限制。readonly:在请求到达 endpoint 前阻止INSERT、UPDATE和DELETE。request_max_redirect:0拒绝重定向,正数启用并限制次数;不再接受-1。request_redirect已弃用。
连接公共或不可信 endpoint 时建议设置 max_response_size,因为 rdf_fdw 会先把取回的 RDF 数据载入内存,再转换为 PostgreSQL 表示。
用户映射
v2.6.0 增加了 Bearer token 认证:
代理凭据也应放在 USER MAPPING:
使用 rdfnode 列的外部表
外部表列应声明为 rdfnode,以保留 RDF term、IRI、blank node、语言标签和 XSD datatype。
v2.6.0 中,RDF 值使用原生 PostgreSQL 列类型的方式已被弃用。已有 native-typed 表仍可工作,但会发出 warning,并且会丢失 RDF term 细节。
查询与下推
rdf_fdw 可下推 WHERE、LIMIT、ORDER BY、DISTINCT 以及受支持的比较和函数。使用 EXPLAIN VERBOSE 查看生成的远端 SPARQL。
Prefix 管理
rdf_fdw 在 sparql schema 下提供 catalog 表和辅助函数,用于复用 SPARQL prefix:
数据修改
可写外部表会将 PostgreSQL INSERT、UPDATE 和 DELETE 转换为 SPARQL UPDATE 请求。示例假设管理员已创建 rdf_write 服务,连接到自己管理的可写端点;公共 DBpedia 服务应保持只读。更新模式中的每个变量都必须映射到非空的 rdfnode 列,且必须设置 sparql_update_pattern。
使用 readonly = true 禁用 server 或 table 的写入。表上显式设置的 readonly = false 会覆盖 server 的 readonly = true;如果必须禁止写入,还应通过远端 endpoint 的凭据和访问控制强制限制。
每次远端写入都会立即由三元组存储提交;PostgreSQL ROLLBACK 无法撤销,应设计应用层补偿,不能假定跨系统原子性。
克隆外部表
rdf_fdw_clone_table() 会把外部表数据分批复制成本地表。v2.5 修复了克隆 RDF term 时的多项往返问题。
SPARQL 函数
sparql schema 实现了许多 SPARQL 1.1 函数和聚合,包括:
sparql.sum、sparql.avg、sparql.min、sparql.max、sparql.group_concat、sparql.sample等聚合sparql.isiri、sparql.isblank、sparql.isliteral、sparql.datatype、sparql.iri、sparql.strdt、sparql.strlang等 RDF term 函数sparql.strlen、sparql.substr、sparql.ucase、sparql.lcase、sparql.contains、sparql.replace等字符串函数- 数值、日期时间、哈希和其他便利函数
注意事项
- 上游最低基线为 PostgreSQL 9.5 或更高版本。
- 取回的 RDF 数据会在转换前累积到内存中。应设置
max_response_size、使用LIMIT,并限制远端结果集规模。 - 优先使用
rdfnode列。RDF term 使用 PostgreSQL 原生类型已被弃用,并会丢失 IRI、语言和 datatype 信息。 - 密钥应放在
USER MAPPING;不要把代理凭据或 endpoint token 写进SERVERoptions。 - 公共 SPARQL endpoint 可能慢或有速率限制。需要时使用
connect_timeout、request_timeout、重试和本地物化。 - 3.0 中扩展不可重定位,且会创建固定的
sparql模式。修改已有安装前,应核对 3.0 的迁移要求。
这个页面对您有帮助吗?
感谢反馈,我们会据此改进这篇文档。
哪里没有解决?(可选)