Skip to content

fix(query): stop explain() panicking on long parameter values - #147

Merged
prrao87 merged 1 commit into
mainfrom
fix/explain-wide-plans
Nov 10, 2026
Merged

prrao87 merged 1 commit into
mainfrom
fix/explain-wide-plans

Conversation

@prrao87

@prrao87 prrao87 commented Nov 10, 2026

Copy link
Copy Markdown
Member

Fixes #145.

Problem

explain() lays the three plans out as a table and padded every line with {:<width$} to the widest line. Rust caps format widths at u16::MAX, so a plan line over 65,535 characters (a list parameter of about 5,000 ints, or a long query vector) panicked. execute() was unaffected.

Removing the panic alone wasn't enough: padding every line to the widest one makes the output grow with lines × width. The graph logical plan prints each list element over several lines, so 6,000 ids produced a 2.3 GB string, and 20,000 ids took 44 s in a debug build.

Change

  • Pad by hand instead of with a format width.
  • Size the column to the widest line of at most 1,000 characters. Longer lines run past the right border rather than widening every row. Nothing is truncated, and ordinary plans print exactly as before.
  • One sentence in docs/cypher.md on the overflow.
ids before after
6,000 panic 0.18 s, 3 MB
20,000 panic 0.60 s, 10 MB

(Debug build, CypherQuery.explain.)

Tests

  • New test_explain_with_large_list_parameter (6,000 ids, line width 77k).
  • make install && uv run --no-sync pytest python/tests/test_explain.py
  • cargo test -p lance-csr --lib, cargo clippy -p lance-csr --all-targets -- -D warnings
  • uv run --project docs --locked zensical build --strict, uvx typos@1.51.1 .

🤖 Generated with Claude Code

Rust's format width is capped at u16::MAX, so padding the explain table
to a line over 65,535 characters (a list parameter of ~5,000 ints)
panicked. Pad by hand, and let lines over 1,000 characters overflow the
border instead of widening every row: padding to them made the output
grow with lines x width (2.3 GB for 6,000 ids).

Fixes #145
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying lance-csr with  Cloudflare Pages  Cloudflare Pages

Latest commit: 405a455
Status: ✅  Deploy successful!
Preview URL: https://b481d3d0.lance-csr.pages.dev
Branch Preview URL: https://fix-explain-wide-plans.lance-csr.pages.dev

View logs

@prrao87
prrao87 merged commit db70889 into main Nov 10, 2026
8 checks passed
@prrao87
prrao87 deleted the fix/explain-wide-plans branch November 10, 2026 14:21
prrao87 added a commit that referenced this pull request Nov 10, 2026
A patch bump: #147 fixes an explain() panic and #148 speeds up string
predicates, with no API changes.
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.

CypherEngine.explain() panics with "Formatting argument out of range" for large list parameters

1 participant