mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +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.
|
// GetVectorFieldSchema get vector field schema from collection schema.
|
||||||
func GetVectorFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
func GetVectorFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
||||||
for _, fieldSchema := range schema.Fields {
|
for _, fieldSchema := range schema.GetFields() {
|
||||||
if IsVectorType(fieldSchema.DataType) {
|
if IsVectorType(fieldSchema.DataType) {
|
||||||
return fieldSchema, nil
|
return fieldSchema, nil
|
||||||
}
|
}
|
||||||
@ -1049,7 +1049,7 @@ func GetVectorFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSch
|
|||||||
// GetVectorFieldSchemas get vector fields schema from collection schema.
|
// GetVectorFieldSchemas get vector fields schema from collection schema.
|
||||||
func GetVectorFieldSchemas(schema *schemapb.CollectionSchema) []*schemapb.FieldSchema {
|
func GetVectorFieldSchemas(schema *schemapb.CollectionSchema) []*schemapb.FieldSchema {
|
||||||
ret := make([]*schemapb.FieldSchema, 0)
|
ret := make([]*schemapb.FieldSchema, 0)
|
||||||
for _, fieldSchema := range schema.Fields {
|
for _, fieldSchema := range schema.GetFields() {
|
||||||
if IsVectorType(fieldSchema.DataType) {
|
if IsVectorType(fieldSchema.DataType) {
|
||||||
ret = append(ret, fieldSchema)
|
ret = append(ret, fieldSchema)
|
||||||
}
|
}
|
||||||
@ -1060,7 +1060,7 @@ func GetVectorFieldSchemas(schema *schemapb.CollectionSchema) []*schemapb.FieldS
|
|||||||
|
|
||||||
// GetPrimaryFieldSchema get primary field schema from collection schema
|
// GetPrimaryFieldSchema get primary field schema from collection schema
|
||||||
func GetPrimaryFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
func GetPrimaryFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
||||||
for _, fieldSchema := range schema.Fields {
|
for _, fieldSchema := range schema.GetFields() {
|
||||||
if fieldSchema.IsPrimaryKey {
|
if fieldSchema.IsPrimaryKey {
|
||||||
return fieldSchema, nil
|
return fieldSchema, nil
|
||||||
}
|
}
|
||||||
@ -1071,7 +1071,7 @@ func GetPrimaryFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSc
|
|||||||
|
|
||||||
// GetPartitionKeyFieldSchema get partition field schema from collection schema
|
// GetPartitionKeyFieldSchema get partition field schema from collection schema
|
||||||
func GetPartitionKeyFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
func GetPartitionKeyFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
||||||
for _, fieldSchema := range schema.Fields {
|
for _, fieldSchema := range schema.GetFields() {
|
||||||
if fieldSchema.IsPartitionKey {
|
if fieldSchema.IsPartitionKey {
|
||||||
return fieldSchema, nil
|
return fieldSchema, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user