mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 09:08:43 +08:00
fix: Support JSON default value in compaction (#45330)
Related to #45329 Fix compaction failure when handling newly added dynamic fields with storage v1 binlogs. The issue occurred because the `GenerateEmptyArrayFromSchema` function did not support JSON data type default values, causing "Unexpected default value" errors during compaction. Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
parent
a4d69031f1
commit
1cf00c6d32
@ -339,6 +339,11 @@ func GenerateEmptyArrayFromSchema(schema *schemapb.FieldSchema, numRows int) (ar
|
||||
bd.AppendValues(
|
||||
lo.RepeatBy(numRows, func(_ int) string { return schema.GetDefaultValue().GetStringData() }),
|
||||
nil)
|
||||
case schemapb.DataType_JSON:
|
||||
bd := builder.(*array.BinaryBuilder)
|
||||
bd.AppendValues(
|
||||
lo.RepeatBy(numRows, func(_ int) []byte { return schema.GetDefaultValue().GetBytesData() }),
|
||||
nil)
|
||||
default:
|
||||
return nil, merr.WrapErrServiceInternal(fmt.Sprintf("Unexpected default value type: %s", schema.GetDataType().String()))
|
||||
}
|
||||
|
||||
@ -190,6 +190,19 @@ func TestGenerateEmptyArray(t *testing.T) {
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
tag: "internal_default_json",
|
||||
field: &schemapb.FieldSchema{
|
||||
DataType: schemapb.DataType_JSON,
|
||||
Nullable: true,
|
||||
DefaultValue: &schemapb.ValueField{
|
||||
Data: &schemapb.ValueField_BytesData{
|
||||
BytesData: []byte(`{}`),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectValue: []byte(`{}`),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user