From 59495b7d6428c4565c5ebaacd5549bb939a19826 Mon Sep 17 00:00:00 2001 From: yangjie01 Date: Mon, 14 Sep 2026 01:40:43 +0800 Subject: [PATCH 1/2] fix(index): error on non-fsl input in NormalizeTransformer NormalizeTransformer downcast the input with as_fixed_size_list, which panics for non-fixed-size-list columns, while sibling KeepFiniteVectors in the same file returns a descriptive Error::index for the same input. Match the sibling's error contract. Assisted-by: GLM-5.3 --- rust/lance-index/src/vector/transform.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/lance-index/src/vector/transform.rs b/rust/lance-index/src/vector/transform.rs index 2faae7b9ce6..06604b4ae90 100644 --- a/rust/lance-index/src/vector/transform.rs +++ b/rust/lance-index/src/vector/transform.rs @@ -66,7 +66,11 @@ impl Transformer for NormalizeTransformer { )) })?; - let data = arr.as_fixed_size_list(); + let data = arr.as_fixed_size_list_opt().ok_or(Error::index(format!( + "Normalize Transform: column {} is not a fixed size list: {}", + self.input_column, + arr.data_type() + )))?; let norm = normalize_fsl(data)?; let transformed = Arc::new(norm); From 95941a6368db5c269ba723394a564a5d3aa1a8fb Mon Sep 17 00:00:00 2001 From: yangjie01 Date: Fri, 18 Sep 2026 22:27:33 +0800 Subject: [PATCH 2/2] test(index): pin the non-fsl error in NormalizeTransformer --- rust/lance-index/src/vector/transform.rs | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rust/lance-index/src/vector/transform.rs b/rust/lance-index/src/vector/transform.rs index 06604b4ae90..d086ae29b24 100644 --- a/rust/lance-index/src/vector/transform.rs +++ b/rust/lance-index/src/vector/transform.rs @@ -240,6 +240,32 @@ mod tests { use lance_arrow::*; use lance_linalg::distance::L2; + /// The transformer is public and its column is named by string, so the + /// column can be any type. `as_fixed_size_list` panics on the wrong one, + /// which is the same situation the missing-column branch above already + /// reports as an error. + #[test] + fn test_normalize_transformer_rejects_non_fsl_column() { + let schema = Schema::new(vec![Field::new("v", DataType::Float32, true)]); + let batch = RecordBatch::try_new( + schema.into(), + vec![Arc::new(Float32Array::from_iter_values([1.0, 2.0]))], + ) + .unwrap(); + + let err = NormalizeTransformer::new("v") + .transform(&batch) + .unwrap_err(); + assert!( + matches!(err, Error::Index { .. }), + "expected an Index error, got: {err:?}" + ); + assert!( + err.to_string().contains("not a fixed size list"), + "unexpected message: {err}" + ); + } + #[tokio::test] async fn test_normalize_transformer_f32() { let data = Float32Array::from_iter_values([1.0, 1.0, 2.0, 2.0].into_iter());