enhance: set dynamic field as nullable with default empty JSON (#46419)

Set the auto-appended dynamic field to be nullable with a default value
of empty JSON object `{}`. This allows collections with dynamic schema
to handle rows that don't have any dynamic fields more gracefully,
avoiding potential null reference issues when the dynamic field is not
explicitly set during insert.

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-12-18 15:15:17 +08:00 committed by GitHub
parent 1414065860
commit bf838eea5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -269,6 +269,12 @@ func (t *createCollectionTask) appendDynamicField(ctx context.Context, schema *s
Description: "dynamic schema",
DataType: schemapb.DataType_JSON,
IsDynamic: true,
Nullable: true,
DefaultValue: &schemapb.ValueField{
Data: &schemapb.ValueField_BytesData{
BytesData: []byte("{}"),
},
},
})
log.Ctx(ctx).Info("append dynamic field", zap.String("collection", schema.Name))
}