From a1c65dec8921a8c310d122f82e7a0b6c1a7311fa Mon Sep 17 00:00:00 2001 From: congqixia Date: Fri, 5 Jul 2024 18:02:09 +0800 Subject: [PATCH] fix: [GoSDK] Avoid creating schema for non-fast CreateCollection (#34448) See also #31293 Signed-off-by: Congqi Xia --- client/collection_options.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/collection_options.go b/client/collection_options.go index 696fe70227..b4eb9a6d2b 100644 --- a/client/collection_options.go +++ b/client/collection_options.go @@ -85,7 +85,7 @@ func (opt *createCollectionOption) WithVarcharPK(varcharPK bool, maxLen int) *cr func (opt *createCollectionOption) Request() *milvuspb.CreateCollectionRequest { // fast create collection - if opt.isFast || opt.schema == nil { + if opt.isFast { var pkField *entity.Field if opt.varcharPK { pkField = entity.NewField().WithDataType(entity.FieldTypeVarChar).WithMaxLength(int64(opt.varcharPKMaxLength)) @@ -101,8 +101,11 @@ func (opt *createCollectionOption) Request() *milvuspb.CreateCollectionRequest { WithField(entity.NewField().WithName(opt.vectorFieldName).WithDataType(entity.FieldTypeFloatVector).WithDim(opt.dim)) } - schemaProto := opt.schema.ProtoMessage() - schemaBytes, _ := proto.Marshal(schemaProto) + var schemaBytes []byte + if opt.schema != nil { + schemaProto := opt.schema.ProtoMessage() + schemaBytes, _ = proto.Marshal(schemaProto) + } return &milvuspb.CreateCollectionRequest{ DbName: "", // reserved fields, not used for now