diff --git a/milvus/utils/Format.ts b/milvus/utils/Format.ts index 86eac69a..6c7ccf8b 100644 --- a/milvus/utils/Format.ts +++ b/milvus/utils/Format.ts @@ -449,7 +449,7 @@ export const buildFieldDataMap = (fields_data: any[]) => { if (key === 'array_data') { field_data = field_data.map((f: any) => { const key = f.data; - return f[key].data; + return key ? f[key].data: []; }); } diff --git a/test/grpc/Insert.spec.ts b/test/grpc/Insert.spec.ts index a010a456..08bf8b1f 100644 --- a/test/grpc/Insert.spec.ts +++ b/test/grpc/Insert.spec.ts @@ -292,12 +292,11 @@ describe(`Insert API`, () => { }); it(`Insert Data on float field expect success`, async () => { - const vectorsData = generateInsertData(COLLECTION_NAME_PARAMS.fields, 10); - + const dataToInsert = generateInsertData(COLLECTION_NAME_PARAMS.fields, 10); const params: InsertReq = { collection_name: COLLECTION_NAME, partition_name: PARTITION_NAME, - fields_data: vectorsData, + fields_data: dataToInsert, }; const res = await milvusClient.insert(params); @@ -310,7 +309,7 @@ describe(`Insert API`, () => { expr: 'id > 0', output_fields: ['json', 'id', 'varChar_array'], }); - // console.log('query', query); + // console.log('query', query.data); expect(query.status.error_code).toEqual(ErrorCode.SUCCESS); const search = await milvusClient.search({ diff --git a/test/tools/data.ts b/test/tools/data.ts index b1cfc913..f8e3342d 100644 --- a/test/tools/data.ts +++ b/test/tools/data.ts @@ -120,6 +120,12 @@ export const genBinaryVector: DataGenerator = params => { */ export const genArray: DataGenerator = params => { const { element_type, max_capacity = 0 } = params!; + + // half chance to generate empty array + if (Math.random() > 0.5) { + return []; + } + return Array.from({ length: max_capacity! }, () => { return dataGenMap[element_type!](params); });