feat: [restful v2] add partition key isolation prop (#34710)

issue: https://github.com/milvus-io/milvus/issues/34332

Signed-off-by: Patrick Weizhi Xu <weizhi.xu@zilliz.com>
pull/34883/head
Patrick Weizhi Xu 2024-07-22 11:29:59 +08:00 committed by GitHub
parent c339df26fc
commit 80c0ae3519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -1246,6 +1246,12 @@ func (h *HandlersV2) createCollection(ctx context.Context, c *gin.Context, anyRe
Value: fmt.Sprintf("%v", httpReq.Params["ttlSeconds"]),
})
}
if _, ok := httpReq.Params["partitionKeyIsolation"]; ok {
req.Properties = append(req.Properties, &commonpb.KeyValuePair{
Key: common.PartitionKeyIsolationKey,
Value: fmt.Sprintf("%v", httpReq.Params["partitionKeyIsolation"]),
})
}
resp, err := wrapperProxy(ctx, c, req, h.checkAuth, false, "/milvus.proto.milvus.MilvusService/CreateCollection", func(reqCtx context.Context, req any) (interface{}, error) {
return h.proxy.CreateCollection(reqCtx, req.(*milvuspb.CreateCollectionRequest))
})

View File

@ -471,7 +471,7 @@ func TestDatabaseWrapper(t *testing.T) {
func TestCreateCollection(t *testing.T) {
postTestCases := []requestBodyTestCase{}
mp := mocks.NewMockProxy(t)
mp.EXPECT().CreateCollection(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Times(12)
mp.EXPECT().CreateCollection(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Times(13)
mp.EXPECT().CreateIndex(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Times(6)
mp.EXPECT().LoadCollection(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Times(6)
mp.EXPECT().CreateIndex(mock.Anything, mock.Anything).Return(commonErrorStatus, nil).Twice()
@ -600,6 +600,15 @@ func TestCreateCollection(t *testing.T) {
errMsg: "missing required parameters, error: `book_xxx` hasn't defined in schema",
errCode: 1802,
})
postTestCases = append(postTestCases, requestBodyTestCase{
path: path,
requestBody: []byte(`{"collectionName": "` + DefaultCollectionName + `", "schema": {
"fields": [
{"fieldName": "book_id", "dataType": "Int64", "isPrimary": true, "isPartitionKey": true, "elementTypeParams": {}},
{"fieldName": "book_intro", "dataType": "FloatVector", "elementTypeParams": {"dim": 2}}
]
}, "params": {"partitionKeyIsolation": "true"}}`),
})
postTestCases = append(postTestCases, requestBodyTestCase{
path: path,
requestBody: []byte(`{"collectionName": "` + DefaultCollectionName + `", "dimension": 2, "metricType": "L2"}`),