mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-29 18:38:44 +08:00
enhance: Avoid panic due to nil schema (#35063)
/kind improvement issue: https://github.com/milvus-io/milvus/discussions/25620 --------- Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
parent
dd0c26cf58
commit
39d25938c5
@ -1038,7 +1038,7 @@ func MergeFieldData(dst []*schemapb.FieldData, src []*schemapb.FieldData) error
|
||||
|
||||
// GetVectorFieldSchema get vector field schema from collection schema.
|
||||
func GetVectorFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
||||
for _, fieldSchema := range schema.Fields {
|
||||
for _, fieldSchema := range schema.GetFields() {
|
||||
if IsVectorType(fieldSchema.DataType) {
|
||||
return fieldSchema, nil
|
||||
}
|
||||
@ -1049,7 +1049,7 @@ func GetVectorFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSch
|
||||
// GetVectorFieldSchemas get vector fields schema from collection schema.
|
||||
func GetVectorFieldSchemas(schema *schemapb.CollectionSchema) []*schemapb.FieldSchema {
|
||||
ret := make([]*schemapb.FieldSchema, 0)
|
||||
for _, fieldSchema := range schema.Fields {
|
||||
for _, fieldSchema := range schema.GetFields() {
|
||||
if IsVectorType(fieldSchema.DataType) {
|
||||
ret = append(ret, fieldSchema)
|
||||
}
|
||||
@ -1060,7 +1060,7 @@ func GetVectorFieldSchemas(schema *schemapb.CollectionSchema) []*schemapb.FieldS
|
||||
|
||||
// GetPrimaryFieldSchema get primary field schema from collection schema
|
||||
func GetPrimaryFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
||||
for _, fieldSchema := range schema.Fields {
|
||||
for _, fieldSchema := range schema.GetFields() {
|
||||
if fieldSchema.IsPrimaryKey {
|
||||
return fieldSchema, nil
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ func GetPrimaryFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSc
|
||||
|
||||
// GetPartitionKeyFieldSchema get partition field schema from collection schema
|
||||
func GetPartitionKeyFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
||||
for _, fieldSchema := range schema.Fields {
|
||||
for _, fieldSchema := range schema.GetFields() {
|
||||
if fieldSchema.IsPartitionKey {
|
||||
return fieldSchema, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user