fix: add validator for cosine metric with int8 (#209)

This commit is contained in:
ZeFeng Yin 2026-03-10 16:09:37 +08:00 committed by GitHub
parent 23ca093fc7
commit ba86c1663d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -160,6 +160,16 @@ Status FieldSchema::validate() const {
"types according to the IP metric");
}
}
if (vector_index_params->metric_type() == MetricType::COSINE) {
if (data_type_ != DataType::VECTOR_FP16 &&
data_type_ != DataType::VECTOR_FP32) {
return Status::InvalidArgument(
"schema validate failed: cosine metric only supports FP32/FP16 "
"data types, but field[",
name_, "]'s data type is ",
DataTypeCodeBook::AsString(data_type_));
}
}
}
} else {
if (index_params_) {