Skip to content

fix(cypher): filter variable-length paths by their property map - #192

Merged
prrao87 merged 1 commit into
mainfrom
fix/var-length-rel-properties
Nov 21, 2026
Merged

prrao87 merged 1 commit into
mainfrom
fix/var-length-rel-properties

Conversation

@prrao87

@prrao87 prrao87 commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Why

A property map on a variable-length relationship was silently ignored. MATCH (a:N {id: 1})-[:R*1..3 {day: 5}]->(b:N) returned every reachable node, as if the map weren't there, with and without the CSR. On a real graph the result was off by orders of magnitude (1.55 billion rows instead of 9,040), and nothing warned that it was wrong. The same map on a single hop filtered correctly.

With this change the map must hold for every relationship on the path, the same rows as WHERE all(r IN relationships(p) WHERE r.day = 5).

Fixes #178.

What changed

  • The variable-length plan operator now carries the relationship's property map. Before, the planner dropped it while building the logical plan.
  • Each hop of the per-length branches applies the map with the same filter a single hop uses.
  • The CSR walk can't check relationship properties, so a variable-length path with a property map uses the per-length branches. That matches how a single hop with a property map already plans. Paths without a map plan exactly as before.
  • A zero-hop match (*0..) has no relationship to check, so the start node still matches itself.

The issue suggested rejecting the map with an error until it was supported. Carrying it through took about as much code and gives the right answer, so I did that instead.

Validation

  • New regression test, with and without the CSR: outgoing, incoming, undirected *0..3, and a named path. The first three return unfiltered rows on 0.13.1; the named path was already correct, since it plans through a different operator, and stays as a guard.
  • cargo test --workspace, cargo clippy --workspace --all-targets -- -D warnings, make test (1756 passed, 1 skipped), make lint, the strict docs build and typos all pass locally.
  • Benchmarks: running now, results to follow in a comment. No benchmark query puts a property map on a variable-length relationship, so plans for the suites should not change.

User impact

Queries that put a property map on a variable-length relationship now return the filtered rows. Before, they returned every path. The variable-length section of the Cypher guide says how the map applies.

🤖 Generated with Claude Code

A property map on a variable-length relationship, such as
[:R*1..3 {day: 5}], was dropped while planning, so every path matched.
Keep the map on VariableLengthExpand and apply it to each hop of the
fixed-length branches. The CSR walk can't filter relationship
properties, so such a path uses those branches instead, as a single
hop with a property map already does.

Fixes #178
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying lance-csr with  Cloudflare Pages  Cloudflare Pages

Latest commit: e1c4ff1
Status: ✅  Deploy successful!
Preview URL: https://7013ddde.lance-csr.pages.dev
Branch Preview URL: https://fix-var-length-rel-propertie.lance-csr.pages.dev

View logs

@prrao87
prrao87 marked this pull request as ready for review November 21, 2026 21:42
@prrao87

prrao87 commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Benchmarks on this branch

Release wheel built from e1c4ff1 (main at d69cef7 plus this fix), run with the CONTRIBUTING harness, two runs per suite and mode. Every query passed its expected-answer check in every run. Load average stayed between 3 and 6.

This measures the branch only. No main wheel was run alongside it, so there is no before-and-after comparison. No benchmark query puts a property map on a variable-length relationship, so their plans should not change.

Machine: Apple M5, 24 GB, macOS 26.6.2. Benchmark commits: graph-benchmark-ldbc 1998520, graph-benchmark-ldbc-complex 220e956, graph-benchmark 995a6ad.

Suite Mode Queries Total, run 1 (ms) Total, run 2 (ms)
graph-benchmark-ldbc memory 30 42.3 43.0
graph-benchmark-ldbc lazy 30 74.9 74.9
graph-benchmark-ldbc-complex memory 14 489.7 487.8
graph-benchmark-ldbc-complex lazy 14 898.2 908.0
graph-benchmark memory 9 56.5 58.0

Per-query means:

graph-benchmark-ldbc, memory
Query run 1 (ms) run 2 (ms)
query1 0.66 0.63
query2 0.54 0.54
query3 0.65 0.66
query4 0.50 0.51
query5 0.79 0.80
query6 0.42 0.43
query7 1.02 1.06
query8 0.63 0.64
query9 0.81 0.83
query10 0.72 0.73
query11 1.49 1.53
query12 0.73 0.76
query13 0.78 0.81
query14 0.52 0.54
query15 0.55 0.58
query16 0.66 0.69
query17 0.90 0.92
query18 0.69 0.71
query19 0.94 0.95
query20 2.02 2.02
query21 0.77 0.78
query22 0.71 0.73
query23 0.74 0.75
query24 0.69 0.70
query25 0.80 0.81
query26 0.75 0.76
query27 0.86 0.88
query28 1.35 1.40
query29 0.69 0.71
query30 18.96 19.09
graph-benchmark-ldbc, lazy
Query run 1 (ms) run 2 (ms)
query1 1.14 1.14
query2 1.41 1.40
query3 0.82 0.81
query4 0.80 0.79
query5 2.15 2.16
query6 0.75 0.75
query7 1.11 1.10
query8 1.72 1.73
query9 1.34 1.34
query10 0.95 0.94
query11 1.98 1.98
query12 6.46 6.55
query13 1.06 1.06
query14 0.69 0.69
query15 0.77 0.76
query16 1.11 1.11
query17 1.40 1.40
query18 1.15 1.14
query19 1.35 1.35
query20 16.77 16.60
query21 0.84 0.83
query22 0.95 0.94
query23 1.24 1.23
query24 1.07 1.06
query25 1.20 1.19
query26 1.06 1.07
query27 1.31 1.30
query28 2.02 2.01
query29 1.03 1.02
query30 19.27 19.44
graph-benchmark-ldbc-complex, memory
Query run 1 (ms) run 2 (ms)
query1 24.20 24.17
query2 2.42 2.43
query3 25.05 25.03
query4 5.74 5.83
query5 70.35 70.77
query6 21.04 21.02
query7 9.76 9.69
query8 2.30 2.29
query9 36.09 36.43
query10 20.45 20.32
query11 2.99 2.98
query12 18.37 18.24
query13 1.15 1.13
query14 249.79 247.43
graph-benchmark-ldbc-complex, lazy
Query run 1 (ms) run 2 (ms)
query1 34.35 33.67
query2 25.17 25.47
query3 166.02 164.99
query4 12.87 12.88
query5 92.48 93.56
query6 22.48 22.29
query7 13.53 13.49
query8 3.30 3.29
query9 221.19 227.14
query10 29.44 28.74
query11 5.42 5.40
query12 18.57 21.48
query13 1.41 1.40
query14 252.01 254.16
graph-benchmark, memory
Query run 1 (ms) run 2 (ms)
query1 7.39 8.06
query2 12.24 12.73
query3 2.69 2.75
query4 1.56 1.57
query5 1.59 1.63
query6 1.84 2.02
query7 3.61 3.62
query8 13.21 13.11
query9 12.35 12.50

@prrao87
prrao87 merged commit 9f162da into main Nov 21, 2026
10 checks passed
@prrao87
prrao87 deleted the fix/var-length-rel-properties branch November 21, 2026 21:53
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.

Property map on a variable-length relationship is silently ignored

1 participant