diff --git a/client/collection.go b/client/collection.go index e0fbcb8a..748d7015 100644 --- a/client/collection.go +++ b/client/collection.go @@ -146,6 +146,9 @@ func (c *GrpcClient) CreateCollection(ctx context.Context, collSchema *entity.Sc } func (c *GrpcClient) requestCreateCollection(ctx context.Context, sch *entity.Schema, opt *createCollOpt, shardNum int32) error { + if opt.EnableDynamicSchema { + sch.EnableDynamicField = true + } bs, err := proto.Marshal(sch.ProtoMessage()) if err != nil { return err diff --git a/common/common.go b/common/common.go index b7394df3..037688e0 100644 --- a/common/common.go +++ b/common/common.go @@ -2,5 +2,5 @@ package common const ( // SDKVersion const value for current version - SDKVersion = `v2.3.2` + SDKVersion = `v2.3.3` ) diff --git a/go.mod b/go.mod index d46d85cd..7585f77e 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/go-faker/faker/v4 v4.1.0 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 - github.com/milvus-io/milvus-proto/go-api/v2 v2.3.2 + github.com/milvus-io/milvus-proto/go-api/v2 v2.3.3 github.com/stretchr/testify v1.8.1 github.com/tidwall/gjson v1.14.4 google.golang.org/grpc v1.48.0 diff --git a/go.sum b/go.sum index 33a249c2..a618254c 100644 --- a/go.sum +++ b/go.sum @@ -159,6 +159,8 @@ github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= github.com/milvus-io/milvus-proto/go-api/v2 v2.3.2 h1:tBcKiEUcX6i3MaFYvMJO1F7R6fIoeLFkg1kSGE1Tvpk= github.com/milvus-io/milvus-proto/go-api/v2 v2.3.2/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek= +github.com/milvus-io/milvus-proto/go-api/v2 v2.3.3 h1:j6Ru7Lq421Ukp+XH8I+ny7dsVF2rLDLLoWpuFgoDZLM= +github.com/milvus-io/milvus-proto/go-api/v2 v2.3.3/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/test/testcases/query_test.go b/test/testcases/query_test.go index b97a29ee..84dc0bc3 100644 --- a/test/testcases/query_test.go +++ b/test/testcases/query_test.go @@ -267,40 +267,38 @@ func TestQueryEmptyOutputFields(t *testing.T) { ctx := createContext(t, time.Second*common.DefaultTimeout) // connect mc := createMilvusClient(ctx, t) - for _, enableDynamic := range []bool{true, false} { - // create, insert, index - collName, ids := createCollectionWithDataIndex(ctx, t, mc, true, true, client.WithEnableDynamicSchema(enableDynamic)) - - // Load collection - errLoad := mc.LoadCollection(ctx, collName, false) - common.CheckErr(t, errLoad, true) + enableDynamic := false + // create, insert, index + collName, ids := createCollectionWithDataIndex(ctx, t, mc, true, true, client.WithEnableDynamicSchema(enableDynamic)) - //query with empty output fields []string{}-> output "int64" - queryEmptyOutputs, _ := mc.QueryByPks( - ctx, collName, []string{common.DefaultPartition}, - entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), - []string{}, - ) - common.CheckOutputFields(t, queryEmptyOutputs, []string{common.DefaultIntFieldName}) + // Load collection + errLoad := mc.LoadCollection(ctx, collName, false) + common.CheckErr(t, errLoad, true) - //query with empty output fields []string{""}-> output "int64" and dynamic field - queryEmptyOutputs, err := mc.QueryByPks( - ctx, collName, []string{common.DefaultPartition}, - entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), - []string{""}, - ) + //query with empty output fields []string{}-> output "int64" + queryEmptyOutputs, _ := mc.QueryByPks( + ctx, collName, []string{common.DefaultPartition}, + entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), + []string{}, + ) + common.CheckOutputFields(t, queryEmptyOutputs, []string{common.DefaultIntFieldName}) - common.CheckErr(t, err, false, "not exist") + //query with empty output fields []string{""}-> output "int64" and dynamic field + _, err := mc.QueryByPks( + ctx, collName, []string{common.DefaultPartition}, + entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), + []string{""}, + ) - // query with "float" output fields -> output "int64, float" - queryFloatOutputs, _ := mc.QueryByPks( - ctx, collName, []string{common.DefaultPartition}, - entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), - []string{common.DefaultFloatFieldName}, - ) - common.CheckOutputFields(t, queryFloatOutputs, []string{common.DefaultIntFieldName, common.DefaultFloatFieldName}) - } + common.CheckErr(t, err, false, "not exist") + // query with "float" output fields -> output "int64, float" + queryFloatOutputs, _ := mc.QueryByPks( + ctx, collName, []string{common.DefaultPartition}, + entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), + []string{common.DefaultFloatFieldName}, + ) + common.CheckOutputFields(t, queryFloatOutputs, []string{common.DefaultIntFieldName, common.DefaultFloatFieldName}) } // test query output int64 and float and floatVector fields @@ -933,7 +931,7 @@ func TestQueryOutputInvalidOutputFieldCount(t *testing.T) { // create, insert, index collName, _ := createCollectionWithDataIndex(ctx, t, mc, true, true, - client.WithEnableDynamicSchema(true), client.WithConsistencyLevel(entity.ClStrong)) + client.WithEnableDynamicSchema(false), client.WithConsistencyLevel(entity.ClStrong)) // Load collection errLoad := mc.LoadCollection(ctx, collName, false) diff --git a/test/testcases/search_test.go b/test/testcases/search_test.go index b44ad826..d32775e3 100644 --- a/test/testcases/search_test.go +++ b/test/testcases/search_test.go @@ -267,52 +267,51 @@ func TestSearchEmptyOutputFields(t *testing.T) { // connect mc := createMilvusClient(ctx, t) - for _, enableDynamic := range []bool{true, false} { - // create collection with data - collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) + enableDynamic := false + // create collection with data + collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) - // load collection - errLoad := mc.LoadCollection(ctx, collName, false) - common.CheckErr(t, errLoad, true) + // load collection + errLoad := mc.LoadCollection(ctx, collName, false) + common.CheckErr(t, errLoad, true) - // search vector output fields []string{} -> [] - sp, _ := entity.NewIndexHNSWSearchParam(74) - searchResPkOutput, errSearch := mc.Search( - ctx, collName, - []string{}, - "", - []string{}, - common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), - common.DefaultFloatVecFieldName, - entity.L2, - common.DefaultTopK, - sp, - ) - common.CheckErr(t, errSearch, true) - common.CheckOutputFields(t, searchResPkOutput[0].Fields, []string{}) - common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) + // search vector output fields []string{} -> [] + sp, _ := entity.NewIndexHNSWSearchParam(74) + searchResPkOutput, errSearch := mc.Search( + ctx, collName, + []string{}, + "", + []string{}, + common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), + common.DefaultFloatVecFieldName, + entity.L2, + common.DefaultTopK, + sp, + ) + common.CheckErr(t, errSearch, true) + common.CheckOutputFields(t, searchResPkOutput[0].Fields, []string{}) + common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) - // search vector output fields []string{""} - _, errSearchExist := mc.Search( - ctx, collName, - []string{}, - "", - []string{""}, - common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), - common.DefaultFloatVecFieldName, - entity.L2, - common.DefaultTopK, - sp, - ) + // search vector output fields []string{""} + _, errSearchExist := mc.Search( + ctx, collName, + []string{}, + "", + []string{""}, + common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), + common.DefaultFloatVecFieldName, + entity.L2, + common.DefaultTopK, + sp, + ) - //if enableDynamic { - // common.CheckErr(t, errSearchExist, true) - // common.CheckOutputFields(t, sp1[0].Fields, []string{""}) - //} else { - common.CheckErr(t, errSearchExist, false, "not exist") - //} - common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) - } + //if enableDynamic { + // common.CheckErr(t, errSearchExist, true) + // common.CheckOutputFields(t, sp1[0].Fields, []string{""}) + //} else { + common.CheckErr(t, errSearchExist, false, "not exist") + //} + common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) } // test search output fields not exist -> error @@ -322,34 +321,34 @@ func TestSearchNotExistOutputFields(t *testing.T) { // connect mc := createMilvusClient(ctx, t) - for _, enableDynamic := range []bool{true, false} { - // create collection with data - collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) + // dynamic schema with unknown field will not have error + enableDynamic := false + // create collection with data + collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) - // load collection - errLoad := mc.LoadCollection(ctx, collName, false) - common.CheckErr(t, errLoad, true) + // load collection + errLoad := mc.LoadCollection(ctx, collName, false) + common.CheckErr(t, errLoad, true) - type notExistOutputFields []string + type notExistOutputFields []string - // search vector output fields not exist, part exist - outputFields := []notExistOutputFields{[]string{"aaa"}, []string{"fields", common.DefaultFloatFieldName}, - []string{"fields", "*"}} - for _, fields := range outputFields { - sp, _ := entity.NewIndexHNSWSearchParam(74) - _, errSearch := mc.Search( - ctx, collName, - []string{}, - "", - fields, - common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), - common.DefaultFloatVecFieldName, - entity.L2, - common.DefaultTopK, - sp, - ) - common.CheckErr(t, errSearch, false, "not exist") - } + // search vector output fields not exist, part exist + outputFields := []notExistOutputFields{[]string{"aaa"}, []string{"fields", common.DefaultFloatFieldName}, + []string{"fields", "*"}} + for _, fields := range outputFields { + sp, _ := entity.NewIndexHNSWSearchParam(74) + _, errSearch := mc.Search( + ctx, collName, + []string{}, + "", + fields, + common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), + common.DefaultFloatVecFieldName, + entity.L2, + common.DefaultTopK, + sp, + ) + common.CheckErr(t, errSearch, false, "not exist") } }