From 382433e4f730921b7565e93c8b2d174061a911ff Mon Sep 17 00:00:00 2001 From: SimFG Date: Thu, 30 Nov 2023 00:26:09 +0800 Subject: [PATCH] Support the dynamic column Signed-off-by: SimFG --- client/insert.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/insert.go b/client/insert.go index fe24db404..0dadd0623 100644 --- a/client/insert.go +++ b/client/insert.go @@ -26,6 +26,8 @@ import ( "github.com/milvus-io/milvus-sdk-go/v2/entity" ) +const MetaFieldName = "$meta" + // Insert Index into collection with column-based format // collName is the collection name // partitionName is the partition to insert, if not specified(empty), default partition will be used @@ -89,6 +91,7 @@ func (c *GrpcClient) processInsertColumns(colSchema *entity.Schema, columns ...e mNameField := make(map[string]*entity.Field) for _, field := range colSchema.Fields { mNameField[field.Name] = field + println("field name:", field.Name) } mNameColumn := make(map[string]entity.Column) var dynamicColumns []entity.Column @@ -159,6 +162,12 @@ func (c *GrpcClient) processInsertColumns(colSchema *entity.Schema, columns ...e } func (c *GrpcClient) mergeDynamicColumns(dynamicName string, rowSize int, columns []entity.Column) (*schemapb.FieldData, error) { + if len(columns) == 1 && columns[0].Name() == MetaFieldName { + data := columns[0].FieldData() + data.FieldName = dynamicName + return data, nil + } + values := make([][]byte, 0, rowSize) for i := 0; i < rowSize; i++ { m := make(map[string]interface{})