mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-13 15:29:12 +01:00
vector: take the list item field from the schema when batching vectors
Lance stores the fixed-size list item as nullable even when the write schema declared it non-null, so PutVectors built batches that no longer matched: expected FixedSizeList(4 x Float32) but found FixedSizeList(4 x non-null Float32).
This commit is contained in:
1 parent
5f79d55fb5
commit
25880a7279
4 files changed
+14
-2
No files matched your search
Generated
+1
@@ -6486,6 +6486,7 @@ dependencies = [
|
||||
"clap",
|
||||
"futures",
|
||||
"lance",
|
||||
"lance-arrow",
|
||||
"lance-linalg",
|
||||
"prost",
|
||||
"prost-types",
|
||||
|
||||
@@ -16,6 +16,7 @@ path = "src/main.rs"
|
||||
weed-vector-core = { path = "../core" }
|
||||
weed-lance-worker = { path = "../../../seaweed-worker/crates/lance" }
|
||||
lance = { version = "10", default-features = false, features = ["aws"] }
|
||||
lance-arrow = "10"
|
||||
lance-linalg = "10"
|
||||
arrow-array = "58"
|
||||
arrow-cast = "58"
|
||||
|
||||
@@ -110,8 +110,18 @@ fn batch_of(vectors: &[pb::Vector], dimension: usize, schema: Arc<Schema>) -> Re
|
||||
.flat_map(|v| v.data.iter().copied())
|
||||
.collect::<Vec<_>>();
|
||||
let values: ArrayRef = Arc::new(Float32Array::from(flat));
|
||||
// Lance stores the list item as nullable even when the write schema
|
||||
// declared it non-null, so the child field must come from the batch's
|
||||
// schema rather than a fixed declaration.
|
||||
let DataType::FixedSizeList(item_field, _) = schema
|
||||
.field_with_name(VECTOR_COLUMN)
|
||||
.map_err(anyhow::Error::from)?
|
||||
.data_type()
|
||||
else {
|
||||
bail!("vector column is not a fixed-size list");
|
||||
};
|
||||
let vectors_array = FixedSizeListArray::try_new(
|
||||
Field::new("item", DataType::Float32, false).into(),
|
||||
item_field.clone(),
|
||||
dimension as i32,
|
||||
values,
|
||||
None,
|
||||
|
||||
@@ -788,7 +788,7 @@ func filterExpr(filter map[string]interface{}) (string, error) {
|
||||
}
|
||||
|
||||
func fieldClause(field string, cond interface{}) (string, error) {
|
||||
col := fmt.Sprintf("json_get_str(`metadata`, '%s')", strings.ReplaceAll(field, "'", "''"))
|
||||
col := fmt.Sprintf("json_get_string(`metadata`, '%s')", strings.ReplaceAll(field, "'", "''"))
|
||||
switch c := cond.(type) {
|
||||
case map[string]interface{}:
|
||||
parts := []string{}
|
||||
|
||||
Reference in new issue
Block a user