Skip to content

feat(graph): add mapped property graphs and bounded SQL graph queries - #1502

Open
wangyunlai-seekdb wants to merge 177 commits into
oceanbase:masterfrom
wangyunlai-seekdb:feat/graph
Open

wangyunlai-seekdb wants to merge 177 commits into
oceanbase:masterfrom
wangyunlai-seekdb:feat/graph

Conversation

@wangyunlai-seekdb

@wangyunlai-seekdb wangyunlai-seekdb commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

任务描述

为 SeekDB 增加基于现有关联表的属性图和有界图查询,使图遍历可以与普通 SQL、向量检索和全文检索组合。

本 PR 汇总 feat/graph 上已逐项交付的图能力。当前分支已合入 master e82516fb9a6f,并完成 Rust PEG 解析器、DDL 和 SQL 工作区接口的适配。

根因

master 已删除旧 ParseNode 解析入口,原图绑定代码无法直接使用。新解析器按语法节点身份保存参数信息,直接复制表达式会丢失参数绑定。此外,master 的 TRUNCATE 会删除并重建新的表 ID;图映射如果仍指向旧表,依赖检查会拒绝操作,绕过检查则会留下失效映射。

解决方案

  • 属性图 CREATE/DROP/SHOW CREATE、JSON 元数据、schema/权限依赖和 8 个 INFORMATION_SCHEMA 视图。
  • GRAPH_TABLE 固定链、单个有界量化段、零跳、OUT/IN/双向遍历、WALK/TRAIL/ACYCLIC,以及有界无权 ANY SHORTEST。
  • PER MATCH/PER STEP、元素 JSON 身份、路径边数组、MATCHNUM()/ELEMENT_NUMBER();LATERAL 关联种子和 prepared 参数重绑保留 SQL bag 语义。
  • 合法形态使用原生反馈循环、批量 DAS 展开、邻接复用和指定两点的双端 BFS;固定链保留普通 JOIN,其他已支持形态保留关系执行。使用普通索引并支持无索引扫描回退。
  • 图语法进入现有 PEG;绑定代码通过类型化构造器生成 Rust 持有的关系语法树,保留参数来源身份。使用已有 SQL resolver 完成表达式类型、权限和计划依赖绑定。
  • TRUNCATE 在同一 DDL 事务内校验映射定义、更新所有引用图的表 ID、图版本、当前/历史 catalog 和内部 ALTER 事件,使 prepared/cache 计划重新绑定。
  • 图工作区接入 master 的 backing allocator;内存不足、取消和超时显式报错。

验证

最终验证提交:25603f2e84cca6519dcdc730b6b28476d515a0b2;已包含 master e82516fb9a6fc13ff9c7757c5290c261ab4751a5。

  • 默认 O2 完整构建通过,版本信息为 RelWithDebInfo;命令为 TMPDIR="$PWD/build-verify/tmp" ./build.py build -o build-verify -j32 --repo_contents_cache= --keep_going //src/observer:seekdb,二进制内嵌 revision 与被测提交一致。
  • 本地 SQL 回归 65/65 通过:全部 52 个 graph 用例,加 13 个解析器、CTE、JOIN、窗口、元数据、整数解码及 spill 用例;无跳过、重试、启动错误。
  • Rust PEG 原生测试 10/10 通过;cargo clippy -p sql-parser --all-targets -- -D warnings 通过。
  • GitHub SeekDB CI 已通过:完整 mysqltest 362/362 通过,无跳过、重试或启动错误。rust-checks 已通过 Clippy、Rust workspace tests、Windows target check 和 cargo audit;License header 与 CLA 也已通过。
  • seekdb_test 验证:通过。 父 pipeline 392358 和 实际测试子 pipeline 392362 均成功,22/22 子任务通过:14 个图专项,加 8 个 mysqltest 分片的 19/19 普通 SQL 用例。逐项读取了全部图专项摘要及 SQL 分片日志,无跳过、无重试、无证据缺失。
  • 图专项包含 schema、binding、access-DDL、outer SQL、composition、batch、identity、path boundary、pruning、partition、snapshot、shortest、failure 和 storage。完整矩阵包括:最短路 784/784、参数绑定 5208/5208、外层 SQL 1608/1608、快照 1324/1324、分区 512/512;15/15 在途 DDL 场景和 50/50 故障清理场景通过。普通 SQL 选择 parser 套件、prepared grammar、递归 CTE rescan/optimize 和 binary protocol。
  • 被测测试仓库提交:e6fedd4380273f316283a6bb788a69b14eb712d3,Linux x86_64,沿用原专项资源与参数。用例更新决定:测试适配提交 更新 PEG 的精确诊断文本/位置,将合法的限定引用字段改为精确结果断言,并将已删除的 allocator 视图替换为现存 SQL 工作区诊断视图。真实语法错误仍断言 1064,取消/超时错误码、完整结果、事务与锁释放断言均保留。与原 master 的 Rust 解析器实跑对照,六条相关普通输入的接受情况和错误位置一致。
  • 本地与 CI 运行同一份 ELF 制品,大小 1,146,317,616 字节,SHA256:5bfb827e42f9669d67f51b5fa9495ff0ad4873c62bcbbdd2b04af1ba6b49bfea。CI 实际包已回读验证,所有子任务的压缩包校验值一致;access-DDL 在 CI 同时核验了真实服务端的完整源码 revision 和 ELF 哈希。复用脚本的空 source 字段、此前的 URL 摘要不作为源码身份依据。
  • git diff --check upstream/master..HEAD 通过。
本轮排查、评审与保留的失败记录
  • 独立评审发现超出 uint64 的路径界限可能被高精度数字节点表示,读取其整数槽会误成零跳。已在转换前验证数字种类,沿现有上限检查拒绝;增加 exact/range 两个超大界限负例。
  • 在现有用例中补充括号表达式的完整路径多重集比较,以及共享映射的两个图、两个 prepared 查询在 edge/vertex TRUNCATE 后的零跳、孤儿边过滤与逐步恢复。
  • 首轮本地 63 项中 61 项通过;新增用例的 SQL 日志缩进已规范,结果值未变;实际 TRUNCATE 回归已修复。最终全组回归结果见上。
  • 解析器迁移和 TRUNCATE 更新分别由无上下文 agent 评审,已修复确认的问题。原语义、native 计划及路径结果断言均保留。随 master 删除失效的旧 C++ 单测链接入口,存储整数解码 mysqltest 保留。
  • 首轮下游 392299 的旧诊断视图和旧 parser 预期导致四个任务失败;原始日志保留,经上述适配后完整重跑通过。没有将该轮失败改记为成功。
  • 原 392156 在 Bazel 外网下载阶段停滞,SQL 未开始,已取消并保留日志。392286 在准备 Rust 工具链时遇到 rsproxy HTTP 504,未执行 SQL。最终流水线复用已在本地构建并验证的精确 ELF;这两轮不计为通过。CI 工具缓存变更 仅复用与源码清单完整 SHA256 一致的 Bazel 工具。
  • 故障专项验证查询错误、会话、事务及锁清理;工作区数据仅作诊断,不作为 heap/DAS 无泄漏或长稳验收证明。

影响范围

本轮在 Linux x86_64、Rust 1.100.0、Bazel 9.3.0 上验证。其他平台以各自 CI 结果为准;未将历史性能、恢复或长稳记录视为当前提交的重新实测。

边界:最多 16 跳、一个量化段;未提供 SIMPLE、无界/加权/全部最短路径、图执行器 PX 或图状态落盘。社区发现、PageRank 等图分析算法不属于本 PR 的内核能力。图属性仍直接映射基表列。

合入理由

提供事务内可组合的基础图检索和可追溯路径结果,并与当前 SQL/存储实现统一。最终验证状态以上述结果为准;本轮不新增性能对比结论。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T04:38:00.880633Z 3240e5d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hnwyllmm
hnwyllmm marked this pull request as draft October 15, 2026 06:31
@hnwyllmm
hnwyllmm marked this pull request as ready for review October 16, 2026 04:30
Introduce a dedicated graph feedback logical operator and keep recursive CTE reuse confined to the physical layer. Rename the path metadata type to GraphPathDesc and extend prepared WALK parameter rebinding coverage.
…tup-retry

fix(storage): retain asynchronous freeze requests across transient admission failures
…ed-collation

fix(sql): restore URL codecs with supported UTF-8 collations
Avoid full macro-buffer initialization for small metadata writes
…est-pruning

Optimize bounded ANY SHORTEST traversal for S1/S2
…ath-state-delivery

Avoid graph path-state realloc peak under 32 MiB work area
…rget-pruning

Reduce repeated target lookups in native shortest traversal
…erator

Optimize bound-pair graph shortest paths with bidirectional search
…on-optimization

Optimize native graph reachability execution
…c9-ic5

Fix graph subquery cardinality estimation
…code

Speed up wide packed integer decoding for IC9
Adapt graph JSON and local DDL calls to the current interfaces, migrate graph mysqltests to the current layout, and preserve metadata rows and aligned-write initialization.
Check the implied depth filter without the independent endpoint exclusion. Preserve the existing estimate threshold and verify that endpoint filters still reduce cardinality.
Construct graph relations with Rust-owned syntax while preserving parameter
provenance, native feedback loops and the existing graph SQL semantics.
Align workarea accounting with the current backing allocator interfaces.
Rebind shared graph metadata atomically when TRUNCATE recreates table IDs,
including schema history and prepared-plan invalidation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant