From 405a45521c430f346ee057d487a2de39691cd8aa Mon Sep 17 00:00:00 2001 From: prrao87 Date: Tue, 10 Nov 2026 14:17:40 +0000 Subject: [PATCH] fix(query): stop explain() panicking on long parameter values 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 --- crates/lance-csr/src/query.rs | 62 ++++++++++------------------- docs/cypher.md | 5 ++- python/python/tests/test_explain.py | 16 ++++++++ 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/crates/lance-csr/src/query.rs b/crates/lance-csr/src/query.rs index f809887..0f1ff3f 100644 --- a/crates/lance-csr/src/query.rs +++ b/crates/lance-csr/src/query.rs @@ -1271,11 +1271,16 @@ impl CypherQuery { ); rows.push(("physical_plan", df_physical_str)); - // Calculate column widths + // Calculate column widths. Lines wider than MAX_PLAN_WIDTH (long parameter + // values, such as a large `IN` list or a query vector) run past the right border + // instead of widening the column: padding every line to them made the output + // grow with lines × width. + const MAX_PLAN_WIDTH: usize = 1_000; let plan_type_width = rows.iter().map(|(t, _)| t.len()).max().unwrap_or(10); let plan_width = rows .iter() - .map(|(_, p)| p.lines().map(|l| l.len()).max().unwrap_or(0)) + .flat_map(|(_, p)| p.lines().map(|l| l.chars().count())) + .filter(|&w| w <= MAX_PLAN_WIDTH) .max() .unwrap_or(50); @@ -1285,52 +1290,27 @@ impl CypherQuery { "-".repeat(plan_type_width + 2), "-".repeat(plan_width + 2) ); + // Pad by hand: `{: = plan_content.lines().collect(); - if lines.is_empty() { - output.push_str(&format!( - "| {: