mirror of https://github.com/milvus-io/milvus.git
fix: Check schema without vector field in proxy (#33211)
Related to #33199 Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/33259/head
parent
2013d97243
commit
f336b2d672
|
@ -293,10 +293,15 @@ func (t *createCollectionTask) PreExecute(ctx context.Context) error {
|
|||
return fmt.Errorf("maximum field's number should be limited to %d", Params.ProxyCfg.MaxFieldNum.GetAsInt())
|
||||
}
|
||||
|
||||
if len(typeutil.GetVectorFieldSchemas(t.schema)) > Params.ProxyCfg.MaxVectorFieldNum.GetAsInt() {
|
||||
vectorFields := len(typeutil.GetVectorFieldSchemas(t.schema))
|
||||
if vectorFields > Params.ProxyCfg.MaxVectorFieldNum.GetAsInt() {
|
||||
return fmt.Errorf("maximum vector field's number should be limited to %d", Params.ProxyCfg.MaxVectorFieldNum.GetAsInt())
|
||||
}
|
||||
|
||||
if vectorFields == 0 {
|
||||
return merr.WrapErrParameterInvalidMsg("schema does not contain vector field")
|
||||
}
|
||||
|
||||
// validate collection name
|
||||
if err := validateCollectionName(t.schema.Name); err != nil {
|
||||
return err
|
||||
|
|
|
@ -754,6 +754,25 @@ func TestCreateCollectionTask(t *testing.T) {
|
|||
err = task.PreExecute(ctx)
|
||||
assert.Error(t, err)
|
||||
|
||||
// without vector field
|
||||
schema = &schemapb.CollectionSchema{
|
||||
Name: collectionName,
|
||||
Description: "",
|
||||
AutoID: false,
|
||||
Fields: []*schemapb.FieldSchema{
|
||||
{
|
||||
Name: "id",
|
||||
DataType: schemapb.DataType_Int64,
|
||||
IsPrimaryKey: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
noVectorSchema, err := proto.Marshal(schema)
|
||||
assert.NoError(t, err)
|
||||
task.CreateCollectionRequest.Schema = noVectorSchema
|
||||
err = task.PreExecute(ctx)
|
||||
assert.Error(t, err)
|
||||
|
||||
task.CreateCollectionRequest = reqBackup
|
||||
|
||||
// validateCollectionName
|
||||
|
|
Loading…
Reference in New Issue