mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-29 18:38:44 +08:00
fix: not add isClusteringKey when describe collection (#36930)
#36928 Signed-off-by: lixinguo <xinguo.li@zilliz.com> Co-authored-by: lixinguo <xinguo.li@zilliz.com>
This commit is contained in:
parent
2441c92ae0
commit
8669153ff2
@ -100,6 +100,7 @@ const (
|
||||
HTTPReturnFieldType = "type"
|
||||
HTTPReturnFieldPrimaryKey = "primaryKey"
|
||||
HTTPReturnFieldPartitionKey = "partitionKey"
|
||||
HTTPReturnFieldClusteringKey = "clusteringKey"
|
||||
HTTPReturnFieldAutoID = "autoId"
|
||||
HTTPReturnFieldElementType = "elementType"
|
||||
HTTPReturnDescription = "description"
|
||||
|
@ -277,7 +277,7 @@ func TestVectorCollectionsDescribe(t *testing.T) {
|
||||
name: "get load status fail",
|
||||
mp: mp2,
|
||||
exceptCode: http.StatusOK,
|
||||
expectedBody: "{\"code\":200,\"data\":{\"collectionName\":\"" + DefaultCollectionName + "\",\"description\":\"\",\"enableDynamicField\":true,\"fields\":[{\"autoId\":false,\"description\":\"\",\"name\":\"book_id\",\"partitionKey\":false,\"primaryKey\":true,\"type\":\"Int64\"},{\"autoId\":false,\"description\":\"\",\"name\":\"word_count\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"Int64\"},{\"autoId\":false,\"description\":\"\",\"name\":\"book_intro\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"FloatVector(2)\"}],\"indexes\":[{\"fieldName\":\"book_intro\",\"indexName\":\"" + DefaultIndexName + "\",\"metricType\":\"COSINE\"}],\"load\":\"\",\"shardsNum\":1}}",
|
||||
expectedBody: "{\"code\":200,\"data\":{\"collectionName\":\"" + DefaultCollectionName + "\",\"description\":\"\",\"enableDynamicField\":true,\"fields\":[{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"book_id\",\"partitionKey\":false,\"primaryKey\":true,\"type\":\"Int64\"},{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"word_count\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"Int64\"},{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"book_intro\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"FloatVector(2)\"}],\"indexes\":[{\"fieldName\":\"book_intro\",\"indexName\":\"" + DefaultIndexName + "\",\"metricType\":\"COSINE\"}],\"load\":\"\",\"shardsNum\":1}}",
|
||||
})
|
||||
|
||||
mp3 := mocks.NewMockProxy(t)
|
||||
@ -288,7 +288,7 @@ func TestVectorCollectionsDescribe(t *testing.T) {
|
||||
name: "get indexes fail",
|
||||
mp: mp3,
|
||||
exceptCode: http.StatusOK,
|
||||
expectedBody: "{\"code\":200,\"data\":{\"collectionName\":\"" + DefaultCollectionName + "\",\"description\":\"\",\"enableDynamicField\":true,\"fields\":[{\"autoId\":false,\"description\":\"\",\"name\":\"book_id\",\"partitionKey\":false,\"primaryKey\":true,\"type\":\"Int64\"},{\"autoId\":false,\"description\":\"\",\"name\":\"word_count\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"Int64\"},{\"autoId\":false,\"description\":\"\",\"name\":\"book_intro\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"FloatVector(2)\"}],\"indexes\":[],\"load\":\"LoadStateLoaded\",\"shardsNum\":1}}",
|
||||
expectedBody: "{\"code\":200,\"data\":{\"collectionName\":\"" + DefaultCollectionName + "\",\"description\":\"\",\"enableDynamicField\":true,\"fields\":[{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"book_id\",\"partitionKey\":false,\"primaryKey\":true,\"type\":\"Int64\"},{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"word_count\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"Int64\"},{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"book_intro\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"FloatVector(2)\"}],\"indexes\":[],\"load\":\"LoadStateLoaded\",\"shardsNum\":1}}",
|
||||
})
|
||||
|
||||
mp4 := mocks.NewMockProxy(t)
|
||||
@ -299,7 +299,7 @@ func TestVectorCollectionsDescribe(t *testing.T) {
|
||||
name: "show collection details success",
|
||||
mp: mp4,
|
||||
exceptCode: http.StatusOK,
|
||||
expectedBody: "{\"code\":200,\"data\":{\"collectionName\":\"" + DefaultCollectionName + "\",\"description\":\"\",\"enableDynamicField\":true,\"fields\":[{\"autoId\":false,\"description\":\"\",\"name\":\"book_id\",\"partitionKey\":false,\"primaryKey\":true,\"type\":\"Int64\"},{\"autoId\":false,\"description\":\"\",\"name\":\"word_count\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"Int64\"},{\"autoId\":false,\"description\":\"\",\"name\":\"book_intro\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"FloatVector(2)\"}],\"indexes\":[{\"fieldName\":\"book_intro\",\"indexName\":\"" + DefaultIndexName + "\",\"metricType\":\"COSINE\"}],\"load\":\"LoadStateLoaded\",\"shardsNum\":1}}",
|
||||
expectedBody: "{\"code\":200,\"data\":{\"collectionName\":\"" + DefaultCollectionName + "\",\"description\":\"\",\"enableDynamicField\":true,\"fields\":[{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"book_id\",\"partitionKey\":false,\"primaryKey\":true,\"type\":\"Int64\"},{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"word_count\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"Int64\"},{\"autoId\":false,\"clusteringKey\":false,\"description\":\"\",\"name\":\"book_intro\",\"partitionKey\":false,\"primaryKey\":false,\"type\":\"FloatVector(2)\"}],\"indexes\":[{\"fieldName\":\"book_intro\",\"indexName\":\"" + DefaultIndexName + "\",\"metricType\":\"COSINE\"}],\"load\":\"LoadStateLoaded\",\"shardsNum\":1}}",
|
||||
})
|
||||
|
||||
for _, tt := range testCases {
|
||||
|
@ -1254,12 +1254,13 @@ func (h *HandlersV2) createCollection(ctx context.Context, c *gin.Context, anyRe
|
||||
}
|
||||
dataType := schemapb.DataType(fieldDataType)
|
||||
fieldSchema := schemapb.FieldSchema{
|
||||
Name: field.FieldName,
|
||||
IsPrimaryKey: field.IsPrimary,
|
||||
IsPartitionKey: field.IsPartitionKey,
|
||||
DataType: dataType,
|
||||
TypeParams: []*commonpb.KeyValuePair{},
|
||||
Nullable: field.Nullable,
|
||||
Name: field.FieldName,
|
||||
IsPrimaryKey: field.IsPrimary,
|
||||
IsPartitionKey: field.IsPartitionKey,
|
||||
IsClusteringKey: field.IsClusteringKey,
|
||||
DataType: dataType,
|
||||
TypeParams: []*commonpb.KeyValuePair{},
|
||||
Nullable: field.Nullable,
|
||||
}
|
||||
|
||||
fieldSchema.DefaultValue, err = convertDefaultValue(field.DefaultValue, dataType)
|
||||
|
@ -166,11 +166,12 @@ func printFieldsV2(fields []*schemapb.FieldSchema) []gin.H {
|
||||
|
||||
func printFieldDetail(field *schemapb.FieldSchema, oldVersion bool) gin.H {
|
||||
fieldDetail := gin.H{
|
||||
HTTPReturnFieldName: field.Name,
|
||||
HTTPReturnFieldPrimaryKey: field.IsPrimaryKey,
|
||||
HTTPReturnFieldPartitionKey: field.IsPartitionKey,
|
||||
HTTPReturnFieldAutoID: field.AutoID,
|
||||
HTTPReturnDescription: field.Description,
|
||||
HTTPReturnFieldName: field.Name,
|
||||
HTTPReturnFieldPrimaryKey: field.IsPrimaryKey,
|
||||
HTTPReturnFieldPartitionKey: field.IsPartitionKey,
|
||||
HTTPReturnFieldClusteringKey: field.IsClusteringKey,
|
||||
HTTPReturnFieldAutoID: field.AutoID,
|
||||
HTTPReturnDescription: field.Description,
|
||||
}
|
||||
if field.GetIsFunctionOutput() {
|
||||
fieldDetail[HTTPReturnFieldIsFunctionOutput] = true
|
||||
|
@ -386,57 +386,63 @@ func TestPrintCollectionDetails(t *testing.T) {
|
||||
indexes := generateIndexes()
|
||||
assert.Equal(t, []gin.H{
|
||||
{
|
||||
HTTPReturnFieldName: FieldBookID,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: true,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldName: FieldBookID,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: true,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
},
|
||||
{
|
||||
HTTPReturnFieldName: FieldWordCount,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldName: FieldWordCount,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
},
|
||||
{
|
||||
HTTPReturnFieldName: FieldBookIntro,
|
||||
HTTPReturnFieldType: "FloatVector(2)",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldName: FieldBookIntro,
|
||||
HTTPReturnFieldType: "FloatVector(2)",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
},
|
||||
}, printFields(coll.Fields))
|
||||
assert.Equal(t, []gin.H{
|
||||
{
|
||||
HTTPReturnFieldName: FieldBookID,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: true,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(100),
|
||||
HTTPReturnFieldName: FieldBookID,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: true,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(100),
|
||||
},
|
||||
{
|
||||
HTTPReturnFieldName: FieldWordCount,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(101),
|
||||
HTTPReturnFieldName: FieldWordCount,
|
||||
HTTPReturnFieldType: "Int64",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(101),
|
||||
},
|
||||
{
|
||||
HTTPReturnFieldName: FieldBookIntro,
|
||||
HTTPReturnFieldType: "FloatVector",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(201),
|
||||
HTTPReturnFieldName: FieldBookIntro,
|
||||
HTTPReturnFieldType: "FloatVector",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(201),
|
||||
Params: []*commonpb.KeyValuePair{
|
||||
{Key: Dim, Value: "2"},
|
||||
},
|
||||
@ -461,44 +467,48 @@ func TestPrintCollectionDetails(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, []gin.H{
|
||||
{
|
||||
HTTPReturnFieldName: "field-varchar",
|
||||
HTTPReturnFieldType: "VarChar(10)",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldName: "field-varchar",
|
||||
HTTPReturnFieldType: "VarChar(10)",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
},
|
||||
{
|
||||
HTTPReturnFieldName: "field-array",
|
||||
HTTPReturnFieldType: "Array",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldName: "field-array",
|
||||
HTTPReturnFieldType: "Array",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
},
|
||||
}, printFields(fields))
|
||||
assert.Equal(t, []gin.H{
|
||||
{
|
||||
HTTPReturnFieldName: "field-varchar",
|
||||
HTTPReturnFieldType: "VarChar",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(0),
|
||||
HTTPReturnFieldName: "field-varchar",
|
||||
HTTPReturnFieldType: "VarChar",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(0),
|
||||
Params: []*commonpb.KeyValuePair{
|
||||
{Key: common.MaxLengthKey, Value: "10"},
|
||||
},
|
||||
},
|
||||
{
|
||||
HTTPReturnFieldName: "field-array",
|
||||
HTTPReturnFieldType: "Array",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(0),
|
||||
HTTPReturnFieldElementType: "Bool",
|
||||
HTTPReturnFieldName: "field-array",
|
||||
HTTPReturnFieldType: "Array",
|
||||
HTTPReturnFieldPartitionKey: false,
|
||||
HTTPReturnFieldClusteringKey: false,
|
||||
HTTPReturnFieldPrimaryKey: false,
|
||||
HTTPReturnFieldAutoID: false,
|
||||
HTTPReturnDescription: "",
|
||||
HTTPReturnFieldID: int64(0),
|
||||
HTTPReturnFieldElementType: "Bool",
|
||||
},
|
||||
}, printFieldsV2(fields))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user