Repository navigation
fix(query): preserve entity properties across untyped matches - #185
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 564d983302
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Hi @MuddyBootsCode, many thanks for the PR!
The fix looks correct to me. One note on the description: the benchmark section reports the disk-backed runs as +10.4% and +7.0% slower, but this change can't slow down typed queries. When all branches already have the same types, merge_branch_field returns immediately and build_union adds no cast, so every typed LDBC query gets the same plan as on main. Could you add one sentence in the PR message above saying typed queries get an unchanged plan, so these deltas are noise? Or diff one EXPLAIN on each build to show it.
That will prevent future humans and their agents from chasing down an unneeded performance fix.
Summary
Fixes #182. An untyped relationship match now returns each node’s own properties. This applies to whole nodes, nodes inside paths, and stored relationship endpoints.
Problem and why it matters
A graph browser uses
MATCH (a)-[]-(b) RETURN a, bto discover connections. On main, this query returned the correct document ID and label but dropped its title. A typed lookup on the same graph returned the title. The planner cast each relationship alternative to the first branch’s record layout, discarding fields that existed only in later branches.Change
Merge marked entity property fields across branches before aligning their records. Reuse the path inventory’s existing rules for nullable fields and incompatible types. Descend through structs and lists to cover relationship endpoints and paths. The extra work is in schema planning and projecting wider records when labels have different fields.
Validation
All 44 SF1 queries returned their expected answers in both storage modes on both builds. Each suite ran twice per wheel per mode. Geometric mean latency changes were +0.7% in memory and +10.4% on disk for the 30-query suite, and −1.5% in memory and +7.0% on disk for the 14-query suite. The typed LDBC queries use the same execution plan on both builds, so we attribute the disk-backed timing differences to run-to-run variation. Five disk-backed queries initially exceeded a 20% slowdown. Their changes ranged from −21.2% to +8.7% in focused repeats. Another validation job was active at the start of every full run, limiting confidence in smaller timing differences.
Baseline
3e281dc3702e610c352314a285dcd051008f6cc1. The benchmarked Rust source matches PR commit564d983302fab658bc5df6accd412b3dc5849f4e. The final commit also includes test and documentation updates made after the benchmark build. Both release wheels used Rust 1.96.0 and the macOS 26.2 Command Line Tools SDK on an Apple M5 Max with 128 GiB running macOS 27.0.1.graph-benchmark-ldbc
Runner commit
199852076ba8dceb345e18eeb2f8ac04c73f3ea1.memory
Geometric mean of per-query branch/main ratios: 1.0068.
lazy
Geometric mean of per-query branch/main ratios: 1.1040.
graph-benchmark-ldbc-complex
Runner commit
a332324f2d4660b03d1d429d8ef99767af3981e5.memory
Geometric mean of per-query branch/main ratios: 0.9854.
lazy
Geometric mean of per-query branch/main ratios: 1.0702.
Follow-up on disk-backed queries
The initial runs shared the Mac with another validation job. These queries were over 20% slower on average in the first comparison. Each was repeated twice per wheel with the same runner options.
User impact
Graph browsers can display each connected node’s name or title from an untyped match. Fields absent from a label are null. Conflicting Arrow types for the same property produce a planning error that names the property. The Cypher guide and operator docs describe the behavior.