mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
fix: Fix bulk import with autoid (#44604)
issue: #44424 Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
parent
30091a3bb7
commit
c25166a202
@ -178,11 +178,7 @@ func AppendSystemFieldsData(task *ImportTask, data *storage.InsertData, rowNum i
|
||||
}
|
||||
pkData, ok := data.Data[pkField.GetFieldID()]
|
||||
allowInsertAutoID, _ := common.IsAllowInsertAutoID(task.req.Schema.GetProperties()...)
|
||||
if pkField.GetAutoID() {
|
||||
if allowInsertAutoID && ok && pkData != nil {
|
||||
// if allowInsertAutoID is true, and pkData is not nil, skip generating primary key data
|
||||
return nil
|
||||
}
|
||||
if pkField.GetAutoID() && (!ok || pkData == nil || pkData.RowNum() == 0 || !allowInsertAutoID) {
|
||||
switch pkField.GetDataType() {
|
||||
case schemapb.DataType_Int64:
|
||||
data.Data[pkField.GetFieldID()] = &storage.Int64FieldData{Data: ids}
|
||||
|
||||
@ -45,6 +45,7 @@ type rowParser struct {
|
||||
structArraySubFields map[string]interface{}
|
||||
pkField *schemapb.FieldSchema
|
||||
dynamicField *schemapb.FieldSchema
|
||||
allowInsertAutoID bool
|
||||
}
|
||||
|
||||
func NewRowParser(schema *schemapb.CollectionSchema, header []string, nullkey string) (RowParser, error) {
|
||||
@ -129,7 +130,6 @@ func NewRowParser(schema *schemapb.CollectionSchema, header []string, nullkey st
|
||||
fmt.Sprintf("value of field is missed: '%s'", field.GetName()))
|
||||
}
|
||||
}
|
||||
|
||||
return &rowParser{
|
||||
nullkey: nullkey,
|
||||
name2Dim: name2Dim,
|
||||
@ -139,6 +139,7 @@ func NewRowParser(schema *schemapb.CollectionSchema, header []string, nullkey st
|
||||
structArraySubFields: structArraySubFields,
|
||||
pkField: pkField,
|
||||
dynamicField: dynamicField,
|
||||
allowInsertAutoID: allowInsertAutoID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -235,6 +236,12 @@ func (r *rowParser) Parse(strArr []string) (Row, error) {
|
||||
row[field.GetFieldID()] = data
|
||||
} else if r.dynamicField != nil {
|
||||
dynamicValues[r.header[index]] = value
|
||||
} else if r.pkField.GetName() == r.header[index] && r.pkField.GetAutoID() && r.allowInsertAutoID {
|
||||
data, err := r.parseEntity(r.pkField, value, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
row[r.pkField.GetFieldID()] = data
|
||||
} else {
|
||||
// from v2.6, we don't intend to return error for redundant fields, just skip it
|
||||
continue
|
||||
|
||||
@ -182,6 +182,12 @@ func (r *rowParser) Parse(raw any) (Row, error) {
|
||||
return err
|
||||
}
|
||||
row[fieldID] = data
|
||||
} else if r.pkField.GetName() == key && r.pkField.GetAutoID() && r.allowInsertAutoID {
|
||||
data, err := r.parseEntity(r.pkField.GetFieldID(), value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
row[r.pkField.GetFieldID()] = data
|
||||
} else if r.dynamicField != nil {
|
||||
// has dynamic field, put redundant pair to dynamicValues
|
||||
dynamicValues[key] = value
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user