Add primaryKey to output fields (#6094)

Signed-off-by: fishpenguin <kun.yu@zilliz.com>
pull/6102/head
yukun 2021-06-24 21:08:14 +08:00 committed by GitHub
parent 4e56218160
commit 9b549e0fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 4 deletions

View File

@ -2026,11 +2026,11 @@ func (rt *RetrieveTask) PreExecute(ctx context.Context) error {
return errors.New(errMsg) return errors.New(errMsg)
} }
rt.Ids = rt.retrieve.Ids rt.Ids = rt.retrieve.Ids
if len(rt.retrieve.OutputFields) == 0 {
schema, err := globalMetaCache.GetCollectionSchema(ctx, collectionName) schema, err := globalMetaCache.GetCollectionSchema(ctx, collectionName)
if err != nil { if err != nil {
return err return err
} }
if len(rt.retrieve.OutputFields) == 0 {
for _, field := range schema.Fields { for _, field := range schema.Fields {
if field.FieldID >= 100 { if field.FieldID >= 100 {
rt.OutputFields = append(rt.OutputFields, field.Name) rt.OutputFields = append(rt.OutputFields, field.Name)
@ -2038,6 +2038,20 @@ func (rt *RetrieveTask) PreExecute(ctx context.Context) error {
} }
} else { } else {
rt.OutputFields = rt.retrieve.OutputFields rt.OutputFields = rt.retrieve.OutputFields
for _, field := range schema.Fields {
if field.IsPrimaryKey {
containPrimaryKey := false
for _, reqFields := range rt.retrieve.OutputFields {
if reqFields == field.Name {
containPrimaryKey = true
}
}
if !containPrimaryKey {
rt.OutputFields = append(rt.OutputFields, field.Name)
}
break
}
}
} }
travelTimestamp := rt.retrieve.TravelTimestamp travelTimestamp := rt.retrieve.TravelTimestamp