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:
Spade A
2025-09-03 19:33:53 +08:00
committed by GitHub
parent d50b365375
commit 825a134739
4 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
+4
View File
@@ -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)
+11
View File
@@ -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