Skip to content

Commit c69a5a2

Browse files
authored
fix: flat FTS panic with prefilter (#3470)
1 parent f508cbd commit c69a5a2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

python/python/tests/test_scalar_index.py

+9
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,15 @@ def test_indexed_filter_with_fts_index(tmp_path):
303303
ds.create_scalar_index("text", "INVERTED")
304304
ds.create_scalar_index("sentiment", "BITMAP")
305305

306+
# append more data to test flat FTS
307+
data = pa.table(
308+
{
309+
"text": ["flat", "search"],
310+
"sentiment": ["positive", "positive"],
311+
}
312+
)
313+
ds = lance.write_dataset(data, tmp_path, mode="append")
314+
306315
results = ds.to_table(
307316
full_text_query="puppy",
308317
filter="sentiment='positive'",

rust/lance-index/src/scalar/inverted/index.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,8 @@ pub fn flat_bm25_search(
10631063

10641064
let score_col = Arc::new(Float32Array::from(scores)) as ArrayRef;
10651065
let batch = batch
1066-
.drop_column(doc_col)?
1067-
.try_with_column(SCORE_FIELD.clone(), score_col)?;
1066+
.try_with_column(SCORE_FIELD.clone(), score_col)?
1067+
.project_by_schema(&FTS_SCHEMA)?; // the scan node would probably scan some extra columns for prefilter, drop them here
10681068
Ok(batch)
10691069
}
10701070

0 commit comments

Comments
 (0)