Skip to content

refactor(query)!: remove call subqueries - #227

Merged
prrao87 merged 1 commit into
mainfrom
refactor/remove-call-subqueries
Nov 28, 2026
Merged

prrao87 merged 1 commit into
mainfrom
refactor/remove-call-subqueries

Conversation

@prrao87

@prrao87 prrao87 commented Nov 28, 2026

Copy link
Copy Markdown
Member

Why

CALL { ... } subqueries are a Neo4j 4.0 extension (GQL has a similar inline call), not part of openCypher 9, and lance-csr positions itself as an openCypher engine. No query in the three benchmark suites uses them, yet they carried their own parser rule, semantic scope rules, a logical Apply operator, a per-row physical operator (ApplyExec) and special cases in the plan cache and the planner. Removing them shrinks the surface the planner work in #223 has to keep correct.

Breaking change: a query that uses CALL { ... } no longer runs.

What changed

  • CALL { ... } and procedure-style CALL name(...) now fail with the same unsupported-feature error as write clauses (NotImplementedError in Python), naming the clause and its position, instead of running or giving a parse error:

    CALL (line 1, column 18). lance-csr doesn't run CALL subqueries or procedures.
    

    A variable named call is not mistaken for the clause.

  • The CALL machinery is gone: the AST variant and its import helpers, the CALL scope checks, the Apply and CallInput logical operators, the CALL-only planner state (preserve_entities, entity-preserving RETURN, cross-branch label checks), the DataFusion builder for it, and ApplyNode/ApplyExec. The plan cache no longer has a CALL bypass. UNION type coercion, which CALL needed first, is kept, so UNION plans are unchanged.

  • The Cypher reference replaces the "Read-only subqueries" section with openCypher forms of the common per-row uses (OPTIONAL MATCH plus count, a further MATCH, and collect(...)[0] after a sorted WITH), with a runnable example. The overview, plan-cache, execution and internals pages, the Python docstring and the Rust crate README drop CALL.

  • Tests: the CALL test module and Rust CALL unit tests are removed; the CALL cases in the path-value and timeout tests are dropped (the timeout test was specifically about CALL inheriting the deadline; a non-CALL expensive-query timeout test already exists). New tests in Rust and Python check the unsupported-feature error. The Node bindings never referenced CALL.

Validation

  • cargo test --workspace, cargo clippy --workspace --all-targets -- -D warnings, cargo fmt --all --check: pass.
  • python/: make install, make test (1817 passed, 5 skipped), make lint: pass. docs/check_snippets.py runs every page; the new example prints the documented output.
  • nodejs/: npm run build:native, npm run build, npm test (90 passed), npm run lint, and the node crate's cargo fmt --check and cargo clippy -D warnings: pass. Generated native.js/native.d.ts are unchanged.
  • uv run --project docs --locked zensical build --strict and uvx typos@1.52.0 .: pass.
  • docs/explain_plans.py (including the 100,000-person graph-benchmark sections) prints byte-identical output from main and this branch, so the pasted plans need no update.

Benchmarks

Following CONTRIBUTING.md: release wheels for main at cd386ef (the engine code on current main; #226 only added the shape suite) and this branch, loaded with uv run --with, main and branch alternated twice per mode, on an Apple M5 at a load average of about 3 to 5. Every suite query passed its expected-answer check and every shape-suite phrasing check passed.

Suite Mode Geomean branch / main main run 2 / run 1
graph-benchmark-ldbc (30) memory +0.7% 1.015
graph-benchmark-ldbc (30) lazy -0.2% 0.999
graph-benchmark-ldbc-complex (14) memory +0.0% 1.000
graph-benchmark-ldbc-complex (14) lazy -1.1% 1.054
shapes, small (50) memory +0.4% 1.003
shapes, small (50) lazy +0.9% 1.001

Plans: I captured explain() for every SF1 query in both modes with both wheels. They match except IC3, whose two inline-property filters (name, type) print in a different order. That order comes from a HashMap and changes between processes on main alone (four captures from the main wheel: three type first, one name first), so it is not caused by this change.

Single-query moves: IC13 lazy shows -28%, but main's two runs of it differ by 79%. The shape suite's largest move is wide_columns/all_ids lazy at +14% (1.42 to 1.63 ms), equal to main's own largest run-to-run gap in that mode. Nothing else moved by more than 10%.

SF1 suites, every query

graph-benchmark-ldbc, memory

Query main ms branch ms Change main run 2 / run 1
q1 0.65 0.66 +2% 1.03
q2 0.57 0.58 +1% 1.01
q3 0.69 0.69 -1% 1.03
q4 0.53 0.54 +1% 1.03
q5 0.83 0.83 -1% 1.00
q6 0.46 0.46 -0% 1.02
q7 1.09 1.09 +0% 1.02
q8 0.67 0.67 +1% 1.01
q9 0.87 0.88 +1% 1.02
q10 0.76 0.77 +1% 1.01
q11 1.57 1.57 +0% 1.01
q12 0.78 0.79 +1% 1.02
q13 0.84 0.85 +2% 1.02
q14 0.56 0.57 +1% 1.02
q15 0.59 0.60 +1% 1.02
q16 0.70 0.71 +1% 1.02
q17 0.94 0.95 +1% 1.01
q18 0.73 0.74 +0% 1.02
q19 0.98 0.98 +0% 1.01
q20 2.11 2.10 -0% 1.00
q21 0.80 0.80 +0% 1.01
q22 0.74 0.75 +1% 1.01
q23 0.77 0.78 +1% 1.02
q24 0.73 0.73 +1% 1.02
q25 0.84 0.84 +0% 1.01
q26 0.79 0.79 -1% 1.01
q27 0.90 0.91 +1% 1.01
q28 1.41 1.44 +2% 1.02
q29 0.73 0.73 +1% 1.02
q30 19.01 19.09 +0% 1.00
geomean +0.7% 1.015

graph-benchmark-ldbc, lazy

Query main ms branch ms Change main run 2 / run 1
q1 1.16 1.16 -0% 1.00
q2 1.41 1.43 +2% 1.00
q3 0.82 0.82 +0% 1.00
q4 0.81 0.81 -0% 0.99
q5 2.20 2.21 +0% 1.00
q6 0.76 0.76 -0% 1.01
q7 1.13 1.13 +0% 0.99
q8 1.78 1.74 -3% 1.02
q9 1.37 1.37 +0% 1.00
q10 0.96 0.96 +0% 1.00
q11 2.01 2.02 +0% 0.99
q12 6.83 6.53 -4% 0.95
q13 1.08 1.08 +0% 0.99
q14 0.71 0.71 -0% 1.00
q15 0.78 0.79 +0% 0.99
q16 1.13 1.13 -1% 1.00
q17 1.43 1.43 -0% 1.00
q18 1.17 1.17 +0% 1.00
q19 1.38 1.37 -0% 1.00
q20 16.70 16.74 +0% 1.00
q21 0.86 0.85 -0% 1.01
q22 0.97 0.97 -1% 0.98
q23 1.27 1.27 -1% 1.00
q24 1.10 1.10 +0% 1.00
q25 1.23 1.23 +0% 1.00
q26 1.09 1.09 +0% 1.00
q27 1.33 1.34 +0% 0.99
q28 2.05 2.07 +1% 1.00
q29 1.06 1.07 +0% 1.01
q30 20.19 19.65 -3% 1.05
geomean -0.2% 0.999

graph-benchmark-ldbc-complex, memory

Query main ms branch ms Change main run 2 / run 1
IC1 24.00 24.79 +3% 1.00
IC2 2.54 2.54 +0% 0.99
IC3 25.86 25.75 -0% 0.99
IC4 5.87 5.89 +0% 1.01
IC5 72.02 69.92 -3% 1.01
IC6 20.83 20.93 +0% 0.99
IC7 9.96 9.93 -0% 1.00
IC8 2.36 2.37 +0% 1.00
IC9 36.99 36.90 -0% 1.00
IC10 20.56 20.58 +0% 1.00
IC11 3.04 3.04 -0% 1.00
IC12 16.37 16.34 -0% 1.00
IC13 1.14 1.14 +0% 1.01
IC14 247.61 247.88 +0% 1.01
geomean +0.0% 1.000

graph-benchmark-ldbc-complex, lazy

Query main ms branch ms Change main run 2 / run 1
IC1 34.24 34.69 +1% 1.02
IC2 24.31 24.54 +1% 0.97
IC3 167.96 166.45 -1% 0.96
IC4 13.08 13.81 +6% 0.99
IC5 97.27 97.46 +0% 0.99
IC6 22.75 25.70 +13% 0.98
IC7 13.75 14.35 +4% 0.98
IC8 3.39 3.55 +5% 0.98
IC9 222.93 239.73 +8% 0.97
IC10 29.41 28.94 -2% 1.01
IC11 5.46 5.38 -1% 1.01
IC12 21.69 19.20 -11% 1.26
IC13 2.01 1.43 -28% 1.79
IC14 263.75 256.56 -3% 1.05
geomean -1.1% 1.054
Shape suite report (`shapes.py report --base main --head branch`)

memory: small graph (20,000 accounts, 229,517 T edges, hub degrees [10, 1000, 10000, 100000])

Runs: main x2, branch x2.

Group Headline Ideal main branch
phrasing slowest / fastest of 8 phrasings 1 2.87x 2.84x
selectivity two filters: slowest / fastest end 1 14.62x 14.76x
selectivity hop order: slowest / fastest 1 1.52x 1.52x
count_rows slowest count / fastest rows <= 1 7.17x 7.13x
hubs cycle: degree 100000 / degree 10 1 16.65x 17.00x
hubs cycle, hub at both ends: degree 100000 / 10 1 23.85x 24.68x
hubs pattern predicate: degree 100000 / 10 1 70.02x 70.43x
hubs cycle at degree 100000: CSR / join <= 1 5.80x 6.05x
hubs predicate at degree 100000: CSR / join <= 1 3.64x 3.61x
optional filtered / unfiltered OPTIONAL MATCH <= 1 3.45x 3.48x
optional filtered OPTIONAL MATCH / filtered MATCH about 1 3.10x 3.10x
wide_columns cross_filter: notes / ids about 1 4.16x 4.15x
wide_columns top_k: notes / ids about 1 2.93x 2.91x
wide_columns far_filter: notes / ids about 1 1.39x 1.38x
wide_columns all: notes / ids > 1 4.36x 4.41x
early_exit LIMIT 10 / all rows, ids << 1 0.36x 0.36x
early_exit LIMIT 10 / all rows, notes << 1 0.59x 0.63x
Query main ms branch ms Change main peak MiB branch peak MiB
phrasing/unnamed_start_inline 0.50 0.50 +1% 1.7 1.7
phrasing/unnamed_start_where 0.51 0.51 -0% 1.7 1.6
phrasing/unnamed_end_inline 0.51 0.51 -1% 1.7 1.7
phrasing/unnamed_end_where 0.52 0.51 -1% 1.7 1.7
phrasing/named_start_inline 1.41 1.42 +0% 10.2 10.0
phrasing/named_start_where 1.43 1.43 -0% 10.8 10.0
phrasing/named_end_inline 1.41 1.42 +1% 10.6 10.6
phrasing/named_end_where 1.43 1.43 -0% 10.7 10.7
selectivity/rows_fwd 10.94 11.10 +1% 3.2 2.8
selectivity/rows_rev 0.75 0.75 +1% 2.1 2.0
selectivity/hop_cheap_first 0.96 0.95 -1% 2.2 2.1
selectivity/hop_hub_first 1.46 1.45 -1% 2.3 2.3
count_rows/count_fwd 5.37 5.37 +0% 3.7 3.7
count_rows/count_rev 5.35 5.35 -0% 3.2 3.6
hubs/cycle_10 1.11 1.14 +3% 2.2 2.1
hubs/cycle_join_10 1.47 1.48 +1% 2.5 2.5
hubs/both_hubs_10 1.05 1.05 +0% 2.0 2.1
hubs/predicate_10 0.58 0.58 -0% 1.8 1.7
hubs/predicate_join_10 2.85 2.87 +1% 4.3 4.1
hubs/cycle_1000 1.23 1.25 +2% 2.3 2.1
hubs/cycle_join_1000 1.50 1.49 -1% 2.5 2.5
hubs/both_hubs_1000 1.22 1.23 +1% 1.9 2.0
hubs/predicate_1000 0.90 0.90 -1% 1.8 1.7
hubs/predicate_join_1000 2.94 2.97 +1% 5.1 4.6
hubs/cycle_10000 3.38 3.41 +1% 2.1 2.1
hubs/cycle_join_10000 1.80 1.80 -0% 3.1 3.1
hubs/both_hubs_10000 3.37 3.48 +3% 2.0 2.0
hubs/predicate_10000 5.14 5.14 +0% 1.7 1.7
hubs/predicate_join_10000 3.95 3.99 +1% 8.5 8.8
hubs/cycle_100000 18.49 19.45 +5% 2.2 2.1
hubs/cycle_join_100000 3.19 3.21 +1% 13.5 12.1
hubs/both_hubs_100000 25.01 25.97 +4% 2.0 2.0
hubs/predicate_100000 40.52 40.59 +0% 1.7 1.8
hubs/predicate_join_100000 11.13 11.23 +1% 50.0 55.1
optional/match 0.59 0.59 -0% 2.5 2.3
optional/optional 0.64 0.64 +0% 2.5 2.4
optional/optional_where 2.22 2.24 +1% 6.9 5.2
optional/match_where 0.72 0.72 +1% 2.4 2.3
wide_columns/far_filter_ids 2.16 2.15 -0% 3.0 3.0
wide_columns/far_filter_notes 2.99 2.97 -1% 27.3 27.4
wide_columns/cross_filter_ids 1.14 1.15 +1% 3.5 3.5
wide_columns/cross_filter_notes 4.75 4.78 +1% 126.6 124.0
wide_columns/top_k_ids 1.34 1.35 +1% 3.3 3.3
wide_columns/top_k_notes 3.93 3.93 +0% 65.5 66.9
wide_columns/all_ids 1.13 1.12 -1% 4.5 4.2
wide_columns/all_notes 4.92 4.93 +0% 189.9 189.3
early_exit/hop_limit_ids 0.39 0.39 -0% 2.0 1.9
early_exit/hop_all_ids 1.09 1.08 -1% 2.5 4.1
early_exit/hop_limit_notes 0.55 0.56 +2% 2.5 2.5
early_exit/hop_all_notes 0.93 0.88 -5% 21.5 21.3
Index main MiB branch MiB main build ms branch build ms
account 18.8 19.0 19 19
ring 26.1 29.0 34 26

main run-to-run geomean: 1.003; largest single-query gap 4%.

lazy: small graph (20,000 accounts, 229,517 T edges, hub degrees [10, 1000, 10000, 100000])

Runs: main x2, branch x2.

Group Headline Ideal main branch
phrasing slowest / fastest of 8 phrasings 1 7.09x 7.07x
selectivity two filters: slowest / fastest end 1 11.64x 11.72x
selectivity hop order: slowest / fastest 1 1.44x 1.41x
count_rows slowest count / fastest rows <= 1 6.53x 6.53x
hubs cycle: degree 100000 / degree 10 1 9.80x 9.88x
hubs cycle, hub at both ends: degree 100000 / 10 1 17.25x 16.38x
hubs pattern predicate: degree 100000 / 10 1 30.05x 30.08x
hubs cycle at degree 100000: CSR / join <= 1 3.50x 3.51x
hubs predicate at degree 100000: CSR / join <= 1 2.94x 2.93x
optional filtered / unfiltered OPTIONAL MATCH <= 1 26.30x 23.95x
optional filtered OPTIONAL MATCH / filtered MATCH about 1 16.05x 15.02x
wide_columns cross_filter: notes / ids about 1 15.61x 17.09x
wide_columns top_k: notes / ids about 1 13.36x 13.67x
wide_columns far_filter: notes / ids about 1 6.56x 6.35x
wide_columns all: notes / ids > 1 17.19x 15.45x
early_exit LIMIT 10 / all rows, ids << 1 0.41x 0.41x
early_exit LIMIT 10 / all rows, notes << 1 0.87x 0.85x
Query main ms branch ms Change main peak MiB branch peak MiB
phrasing/unnamed_start_inline 0.65 0.65 -0% 2.2 2.2
phrasing/unnamed_start_where 0.65 0.66 +2% 2.2 2.1
phrasing/unnamed_end_inline 0.65 0.65 -0% 2.1 2.2
phrasing/unnamed_end_where 0.66 0.65 -2% 2.2 2.1
phrasing/named_start_inline 4.51 4.53 +1% 92.1 92.2
phrasing/named_start_where 4.59 4.55 -1% 92.3 92.2
phrasing/named_end_inline 4.52 4.51 -0% 92.3 92.2
phrasing/named_end_where 4.56 4.57 +0% 92.1 92.0
selectivity/rows_fwd 12.84 13.04 +2% 6.2 6.0
selectivity/rows_rev 1.10 1.11 +1% 3.4 3.1
selectivity/hop_cheap_first 1.27 1.29 +2% 2.8 2.7
selectivity/hop_hub_first 1.83 1.82 -1% 2.8 2.7
count_rows/count_fwd 7.20 7.26 +1% 7.1 7.7
count_rows/count_rev 7.16 7.22 +1% 7.6 7.9
hubs/cycle_10 2.00 2.01 +0% 3.3 3.5
hubs/cycle_join_10 3.36 3.34 -1% 5.8 5.7
hubs/both_hubs_10 1.58 1.57 -1% 2.7 2.3
hubs/predicate_10 1.38 1.38 +0% 3.5 3.1
hubs/predicate_join_10 5.64 5.66 +0% 16.2 14.8
hubs/cycle_1000 2.26 2.25 -1% 3.8 3.7
hubs/cycle_join_1000 3.36 3.36 -0% 6.0 5.5
hubs/both_hubs_1000 1.80 1.80 +0% 2.3 2.3
hubs/predicate_1000 1.80 1.82 +1% 3.0 3.7
hubs/predicate_join_1000 5.74 5.75 +0% 16.5 13.0
hubs/cycle_10000 4.42 4.40 -0% 3.5 3.6
hubs/cycle_join_10000 3.69 3.67 -1% 7.3 6.1
hubs/both_hubs_10000 3.93 3.95 +0% 2.3 2.4
hubs/predicate_10000 6.01 6.03 +0% 3.3 3.2
hubs/predicate_join_10000 6.46 6.51 +1% 19.5 19.3
hubs/cycle_100000 19.62 19.86 +1% 3.4 4.6
hubs/cycle_join_100000 5.60 5.65 +1% 23.9 23.5
hubs/both_hubs_100000 27.21 25.66 -6% 2.4 2.3
hubs/predicate_100000 41.46 41.59 +0% 3.4 3.1
hubs/predicate_join_100000 14.11 14.19 +1% 59.0 60.4
optional/match 0.75 0.75 -0% 3.2 3.1
optional/optional 0.80 0.82 +2% 2.9 3.2
optional/optional_where 21.09 19.59 -7% 27.3 26.9
optional/match_where 1.31 1.30 -1% 3.8 3.9
wide_columns/far_filter_ids 3.05 3.07 +1% 5.5 5.2
wide_columns/far_filter_notes 20.03 19.49 -3% 114.1 108.0
wide_columns/cross_filter_ids 1.49 1.45 -3% 5.0 4.3
wide_columns/cross_filter_notes 23.31 24.77 +6% 258.7 249.8
wide_columns/top_k_ids 1.67 1.72 +3% 4.4 4.6
wide_columns/top_k_notes 22.38 23.57 +5% 215.5 213.4
wide_columns/all_ids 1.42 1.63 +14% 5.9 5.7
wide_columns/all_notes 24.48 25.19 +3% 286.8 288.5
early_exit/hop_limit_ids 0.48 0.50 +3% 2.2 2.2
early_exit/hop_all_ids 1.17 1.22 +4% 5.9 5.8
early_exit/hop_limit_notes 5.40 5.70 +6% 118.8 118.8
early_exit/hop_all_notes 6.18 6.69 +8% 117.5 121.4
Index main MiB branch MiB main build ms branch build ms
account 19.5 18.9 19 18
ring 30.5 28.5 26 26

main run-to-run geomean: 1.001; largest single-query gap 14%.

🤖 Generated with Claude Code

CALL subqueries are a Neo4j extension, not part of openCypher 9, and no
query in the benchmark suites uses them. Drop the parser rule, the AST
variant and its import helpers, the semantic checks, the logical Apply
and CallInput operators, the DataFusion builder and the ApplyExec
operator, along with the plan-cache bypass and planner state that only
CALL used.

A query with CALL { ... } or CALL proc() now raises an unsupported-feature
error naming the clause and its position, like write clauses do. The
Cypher reference shows openCypher forms of the common per-row uses.

BREAKING CHANGE: queries that use CALL { ... } no longer run.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Deploying lance-csr with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4838555
Status: ✅  Deploy successful!
Preview URL: https://7ead4fbc.lance-csr.pages.dev
Branch Preview URL: https://refactor-remove-call-subquer.lance-csr.pages.dev

View logs

@prrao87
prrao87 marked this pull request as ready for review November 28, 2026 00:57
@prrao87
prrao87 merged commit 1d01a8d into main Nov 28, 2026
10 checks passed
@prrao87
prrao87 deleted the refactor/remove-call-subqueries branch November 28, 2026 00:57
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