From bf838eea5db0dfb69ecf127b5221696d10e04f88 Mon Sep 17 00:00:00 2001 From: congqixia Date: Thu, 18 Dec 2025 15:15:17 +0800 Subject: [PATCH] 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 --- internal/rootcoord/create_collection_task.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/rootcoord/create_collection_task.go b/internal/rootcoord/create_collection_task.go index 46d0beb986..cd841a5a27 100644 --- a/internal/rootcoord/create_collection_task.go +++ b/internal/rootcoord/create_collection_task.go @@ -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)) }