From c2693ea284db152d68bee1fa073b624c9e8f9c01 Mon Sep 17 00:00:00 2001 From: groot Date: Fri, 28 Jul 2023 15:25:03 +0800 Subject: [PATCH] Fix a crash bug of bulkinsert for dynamic field (#25982) Signed-off-by: yhmo --- internal/util/importutil/import_util.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/util/importutil/import_util.go b/internal/util/importutil/import_util.go index d26046a417..636f6beafd 100644 --- a/internal/util/importutil/import_util.go +++ b/internal/util/importutil/import_util.go @@ -445,11 +445,12 @@ func fillDynamicData(blockData BlockData, collectionSchema *schemapb.CollectionS } } - if dynamicData.RowNum() == 0 { - // fill the dynamic data by row count + if dynamicData.RowNum() < rowCount { + // fill the dynamic data by an empty JSON object, make sure the row count is eaual to other fields data := dynamicData.(*storage.JSONFieldData) bs := []byte("{}") - for i := 0; i < rowCount; i++ { + dynamicRowCount := dynamicData.RowNum() + for i := 0; i < rowCount-dynamicRowCount; i++ { data.Data = append(data.Data, bs) } }