From 632ecaf460033c8a99d0483f89508492b3171013 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 17 Nov 2025 11:58:20 -0800 Subject: [PATCH] fix: convert some panics into errors --- rust/lance/src/dataset/scanner.rs | 7 ++++--- rust/lance/src/index/vector/builder.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rust/lance/src/dataset/scanner.rs b/rust/lance/src/dataset/scanner.rs index f6a60959317..848a33bc3dc 100644 --- a/rust/lance/src/dataset/scanner.rs +++ b/rust/lance/src/dataset/scanner.rs @@ -292,9 +292,10 @@ impl LanceFilter { }) } #[cfg(not(feature = "substrait"))] - Self::Substrait(_) => { - panic!("Substrait filter is not supported in this build"); - } + Self::Substrait(_) => Err(Error::NotSupported { + source: "Substrait filter is not supported in this build".into(), + location: location!(), + }), Self::Datafusion(expr) => Ok(expr.clone()), } } diff --git a/rust/lance/src/index/vector/builder.rs b/rust/lance/src/index/vector/builder.rs index 65029277057..e6d0fb16c51 100644 --- a/rust/lance/src/index/vector/builder.rs +++ b/rust/lance/src/index/vector/builder.rs @@ -652,10 +652,10 @@ impl IvfIndexBuilder .peekable(), ); - let batch = transformed_stream.as_mut().peek().await; + let batch = transformed_stream.as_mut().peek_mut().await; let schema = match batch { Some(Ok(b)) => b.schema(), - Some(Err(e)) => panic!("do this better: error reading first batch: {:?}", e), + Some(Err(e)) => return Err(std::mem::replace(e, Error::Stop)), None => { log::info!("no data to shuffle"); self.shuffle_reader = Some(Arc::new(IvfShufflerReader::new(