diff --git a/internal/proxy/task.go b/internal/proxy/task.go index 27d300f485..45c399c6c4 100644 --- a/internal/proxy/task.go +++ b/internal/proxy/task.go @@ -3165,7 +3165,7 @@ func getPrimaryKeysFromExpr(schema *schemapb.CollectionSchema, expr string) (res // delete request only support expr "id in [a, b]" termExpr, ok := plan.Node.(*planpb.PlanNode_Predicates).Predicates.Expr.(*planpb.Expr_TermExpr) if !ok { - return res, 0, fmt.Errorf("invalid plan node type") + return res, 0, fmt.Errorf("invalid plan node type, only pk in [1, 2] supported") } res = &schemapb.IDs{} diff --git a/internal/proxy/task_test.go b/internal/proxy/task_test.go index 813eda76d1..6c154a38f0 100644 --- a/internal/proxy/task_test.go +++ b/internal/proxy/task_test.go @@ -1844,6 +1844,42 @@ func TestTask_Int64PrimaryKey(t *testing.T) { assert.NoError(t, task.PreExecute(ctx)) assert.NoError(t, task.Execute(ctx)) assert.NoError(t, task.PostExecute(ctx)) + + task2 := &deleteTask{ + Condition: NewTaskCondition(ctx), + BaseDeleteTask: msgstream.DeleteMsg{ + BaseMsg: msgstream.BaseMsg{}, + DeleteRequest: internalpb.DeleteRequest{ + Base: &commonpb.MsgBase{ + MsgType: commonpb.MsgType_Delete, + MsgID: 0, + Timestamp: 0, + SourceID: Params.ProxyCfg.GetNodeID(), + }, + CollectionName: collectionName, + PartitionName: partitionName, + }, + }, + deleteExpr: "int64 not in [0, 1]", + ctx: ctx, + result: &milvuspb.MutationResult{ + Status: &commonpb.Status{ + ErrorCode: commonpb.ErrorCode_Success, + Reason: "", + }, + IDs: nil, + SuccIndex: nil, + ErrIndex: nil, + Acknowledged: false, + InsertCnt: 0, + DeleteCnt: 0, + UpsertCnt: 0, + Timestamp: 0, + }, + chMgr: chMgr, + chTicker: ticker, + } + assert.Error(t, task2.PreExecute(ctx)) }) } @@ -2064,6 +2100,42 @@ func TestTask_VarCharPrimaryKey(t *testing.T) { assert.NoError(t, task.PreExecute(ctx)) assert.NoError(t, task.Execute(ctx)) assert.NoError(t, task.PostExecute(ctx)) + + task2 := &deleteTask{ + Condition: NewTaskCondition(ctx), + BaseDeleteTask: msgstream.DeleteMsg{ + BaseMsg: msgstream.BaseMsg{}, + DeleteRequest: internalpb.DeleteRequest{ + Base: &commonpb.MsgBase{ + MsgType: commonpb.MsgType_Delete, + MsgID: 0, + Timestamp: 0, + SourceID: Params.ProxyCfg.GetNodeID(), + }, + CollectionName: collectionName, + PartitionName: partitionName, + }, + }, + deleteExpr: "varChar not in [\"milvus\", \"test\"]", + ctx: ctx, + result: &milvuspb.MutationResult{ + Status: &commonpb.Status{ + ErrorCode: commonpb.ErrorCode_Success, + Reason: "", + }, + IDs: nil, + SuccIndex: nil, + ErrIndex: nil, + Acknowledged: false, + InsertCnt: 0, + DeleteCnt: 0, + UpsertCnt: 0, + Timestamp: 0, + }, + chMgr: chMgr, + chTicker: ticker, + } + assert.Error(t, task2.PreExecute(ctx)) }) }