mirror of https://github.com/milvus-io/milvus.git
fix: to add check in partition key field when set nullable==true (#36218)
#36213 Signed-off-by: lixinguo <xinguo.li@zilliz.com> Co-authored-by: lixinguo <xinguo.li@zilliz.com>pull/36251/head^2
parent
3bc7d63be9
commit
2d05b7f219
|
@ -219,6 +219,10 @@ func (t *createCollectionTask) validatePartitionKey() error {
|
|||
return errors.New("the partition key field must not be primary field")
|
||||
}
|
||||
|
||||
if field.GetNullable() {
|
||||
return merr.WrapErrParameterInvalidMsg("partition key field not support nullable")
|
||||
}
|
||||
|
||||
// The type of the partition key field can only be int64 and varchar
|
||||
if field.DataType != schemapb.DataType_Int64 && field.DataType != schemapb.DataType_VarChar {
|
||||
return errors.New("the data type of partition key should be Int64 or VarChar")
|
||||
|
|
|
@ -3216,6 +3216,16 @@ func TestCreateCollectionTaskWithPartitionKey(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
partitionKeyField.DataType = schemapb.DataType_Int64
|
||||
|
||||
// test partition key set nullable == true
|
||||
partitionKeyField.Nullable = true
|
||||
marshaledSchema, err = proto.Marshal(schema)
|
||||
assert.NoError(t, err)
|
||||
task.Schema = marshaledSchema
|
||||
err = task.PreExecute(ctx)
|
||||
assert.Error(t, err)
|
||||
partitionKeyField.DataType = schemapb.DataType_Int64
|
||||
partitionKeyField.Nullable = false
|
||||
|
||||
// test partition key field not primary key field
|
||||
primaryField, _ := typeutil.GetPrimaryFieldSchema(schema)
|
||||
primaryField.IsPartitionKey = true
|
||||
|
|
Loading…
Reference in New Issue