mirror of
https://github.com/milvus-io/milvus.git
synced 2026-07-21 02:05:41 +00:00
feat: impl StructArray -- reject json types for struct (#44190)
issue: https://github.com/milvus-io/milvus/issues/42148 --------- Signed-off-by: SpadeA <tangchenjie1210@gmail.com>
This commit is contained in:
@@ -501,7 +501,7 @@ TEST_P(GrowingTest, FillVectorArrayData) {
|
||||
|
||||
TEST(GrowingTest, LoadVectorArrayData) {
|
||||
auto schema = std::make_shared<Schema>();
|
||||
auto metric_type = knowhere::metric::L2;
|
||||
auto metric_type = knowhere::metric::MAX_SIM;
|
||||
auto int64_field = schema->AddDebugField("int64", DataType::INT64);
|
||||
auto array_float_vector = schema->AddDebugVectorArrayField(
|
||||
"array_vec", DataType::VECTOR_FLOAT, 128, metric_type);
|
||||
|
||||
@@ -2277,7 +2277,7 @@ TEST(Sealed, SearchSortedPk) {
|
||||
|
||||
TEST(Sealed, QueryVectorArrayAllFields) {
|
||||
auto schema = std::make_shared<Schema>();
|
||||
auto metric_type = knowhere::metric::L2;
|
||||
auto metric_type = knowhere::metric::MAX_SIM;
|
||||
auto int64_field = schema->AddDebugField("int64", DataType::INT64);
|
||||
auto array_vec = schema->AddDebugVectorArrayField(
|
||||
"array_vec", DataType::VECTOR_FLOAT, 128, metric_type);
|
||||
|
||||
@@ -592,6 +592,10 @@ func ValidateFieldsInStruct(field *schemapb.FieldSchema, schema *schemapb.Collec
|
||||
return fmt.Errorf("Nested array is not supported %s", field.Name)
|
||||
}
|
||||
|
||||
if field.ElementType == schemapb.DataType_JSON {
|
||||
return fmt.Errorf("JSON is not supported for fields in struct, fieldName = %s", field.Name)
|
||||
}
|
||||
|
||||
if field.DataType == schemapb.DataType_Array {
|
||||
if typeutil.IsVectorType(field.GetElementType()) {
|
||||
return fmt.Errorf("Inconsistent schema: element type of array field %s is a vector type", field.Name)
|
||||
|
||||
@@ -3901,6 +3901,17 @@ func TestValidateFieldsInStruct(t *testing.T) {
|
||||
assert.Contains(t, err.Error(), "Fields in StructArrayField can only be array or array of struct")
|
||||
})
|
||||
|
||||
t.Run("JSON not supported in struct", func(t *testing.T) {
|
||||
field := &schemapb.FieldSchema{
|
||||
Name: "json_field",
|
||||
DataType: schemapb.DataType_Array,
|
||||
ElementType: schemapb.DataType_JSON,
|
||||
}
|
||||
err := ValidateFieldsInStruct(field, schema)
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "JSON is not supported for fields in struct")
|
||||
})
|
||||
|
||||
t.Run("nested array not supported", func(t *testing.T) {
|
||||
testCases := []struct {
|
||||
elementType schemapb.DataType
|
||||
|
||||
Reference in New Issue
Block a user