Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip output invalid field case #628

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 29 additions & 27 deletions test/testcases/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,42 +263,44 @@ func TestQueryNonPrimaryFields(t *testing.T) {

// test query empty or one scalar output fields
func TestQueryEmptyOutputFields(t *testing.T) {
t.Skip("https://github.com/milvus-io/milvus/issues/28465")
t.Parallel()
ctx := createContext(t, time.Second*common.DefaultTimeout)
// connect
mc := createMilvusClient(ctx, t)
enableDynamic := false
// create, insert, index
collName, ids := createCollectionWithDataIndex(ctx, t, mc, true, true, client.WithEnableDynamicSchema(enableDynamic))
for _, enableDynamic := range []bool{true, false} {
// create, insert, index
collName, ids := createCollectionWithDataIndex(ctx, t, mc, true, true, client.WithEnableDynamicSchema(enableDynamic))

// Load collection
errLoad := mc.LoadCollection(ctx, collName, false)
common.CheckErr(t, errLoad, true)
// Load collection
errLoad := mc.LoadCollection(ctx, collName, false)
common.CheckErr(t, errLoad, true)

//query with empty output fields []string{}-> output "int64"
queryEmptyOutputs, _ := mc.QueryByPks(
ctx, collName, []string{common.DefaultPartition},
entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]),
[]string{},
)
common.CheckOutputFields(t, queryEmptyOutputs, []string{common.DefaultIntFieldName})
//query with empty output fields []string{}-> output "int64"
queryEmptyOutputs, _ := mc.QueryByPks(
ctx, collName, []string{common.DefaultPartition},
entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]),
[]string{},
)
common.CheckOutputFields(t, queryEmptyOutputs, []string{common.DefaultIntFieldName})

//query with empty output fields []string{""}-> output "int64" and dynamic field
_, err := mc.QueryByPks(
ctx, collName, []string{common.DefaultPartition},
entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]),
[]string{""},
)
//query with empty output fields []string{""}-> output "int64" and dynamic field
queryEmptyOutputs, err := mc.QueryByPks(
ctx, collName, []string{common.DefaultPartition},
entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]),
[]string{""},
)

common.CheckErr(t, err, false, "not exist")
common.CheckErr(t, err, false, "not exist")

// query with "float" output fields -> output "int64, float"
queryFloatOutputs, _ := mc.QueryByPks(
ctx, collName, []string{common.DefaultPartition},
entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]),
[]string{common.DefaultFloatFieldName},
)
common.CheckOutputFields(t, queryFloatOutputs, []string{common.DefaultIntFieldName, common.DefaultFloatFieldName})
// query with "float" output fields -> output "int64, float"
queryFloatOutputs, _ := mc.QueryByPks(
ctx, collName, []string{common.DefaultPartition},
entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]),
[]string{common.DefaultFloatFieldName},
)
common.CheckOutputFields(t, queryFloatOutputs, []string{common.DefaultIntFieldName, common.DefaultFloatFieldName})
}
}

// test query output int64 and float and floatVector fields
Expand Down
136 changes: 70 additions & 66 deletions test/testcases/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,93 +262,97 @@ func TestSearchPartitions(t *testing.T) {

// test search empty output fields []string{} -> [], []string{""}
func TestSearchEmptyOutputFields(t *testing.T) {
t.Skip("https://github.com/milvus-io/milvus/issues/28465")
t.Parallel()
ctx := createContext(t, time.Second*common.DefaultTimeout)
// connect
mc := createMilvusClient(ctx, t)

enableDynamic := false
// create collection with data
collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic))
for _, enableDynamic := range []bool{true, false} {
// create collection with data
collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic))

// load collection
errLoad := mc.LoadCollection(ctx, collName, false)
common.CheckErr(t, errLoad, true)
// load collection
errLoad := mc.LoadCollection(ctx, collName, false)
common.CheckErr(t, errLoad, true)

// search vector output fields []string{} -> []
sp, _ := entity.NewIndexHNSWSearchParam(74)
searchResPkOutput, errSearch := mc.Search(
ctx, collName,
[]string{},
"",
[]string{},
common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector),
common.DefaultFloatVecFieldName,
entity.L2,
common.DefaultTopK,
sp,
)
common.CheckErr(t, errSearch, true)
common.CheckOutputFields(t, searchResPkOutput[0].Fields, []string{})
common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK)
// search vector output fields []string{} -> []
sp, _ := entity.NewIndexHNSWSearchParam(74)
searchResPkOutput, errSearch := mc.Search(
ctx, collName,
[]string{},
"",
[]string{},
common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector),
common.DefaultFloatVecFieldName,
entity.L2,
common.DefaultTopK,
sp,
)
common.CheckErr(t, errSearch, true)
common.CheckOutputFields(t, searchResPkOutput[0].Fields, []string{})
common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK)

// search vector output fields []string{""}
_, errSearchExist := mc.Search(
ctx, collName,
[]string{},
"",
[]string{""},
common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector),
common.DefaultFloatVecFieldName,
entity.L2,
common.DefaultTopK,
sp,
)
// search vector output fields []string{""}
_, errSearchExist := mc.Search(
ctx, collName,
[]string{},
"",
[]string{""},
common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector),
common.DefaultFloatVecFieldName,
entity.L2,
common.DefaultTopK,
sp,
)

//if enableDynamic {
// common.CheckErr(t, errSearchExist, true)
// common.CheckOutputFields(t, sp1[0].Fields, []string{""})
//} else {
common.CheckErr(t, errSearchExist, false, "not exist")
//}
common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK)
//if enableDynamic {
// common.CheckErr(t, errSearchExist, true)
// common.CheckOutputFields(t, sp1[0].Fields, []string{""})
//} else {
common.CheckErr(t, errSearchExist, false, "not exist")
//}
common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK)
}
}

// test search output fields not exist -> error
// test search output fields not exist -> output existed fields
func TestSearchNotExistOutputFields(t *testing.T) {
t.Skip("https://github.com/milvus-io/milvus/issues/28465")
t.Parallel()
ctx := createContext(t, time.Second*common.DefaultTimeout)
// connect
mc := createMilvusClient(ctx, t)

// dynamic schema with unknown field will not have error
enableDynamic := false
// create collection with data
collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic))
for _, enableDynamic := range []bool{false} {
// create collection with data
collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic))

// load collection
errLoad := mc.LoadCollection(ctx, collName, false)
common.CheckErr(t, errLoad, true)
// load collection
errLoad := mc.LoadCollection(ctx, collName, false)
common.CheckErr(t, errLoad, true)

type notExistOutputFields []string
type notExistOutputFields []string

// search vector output fields not exist, part exist
outputFields := []notExistOutputFields{[]string{"aaa"}, []string{"fields", common.DefaultFloatFieldName},
[]string{"fields", "*"}}
for _, fields := range outputFields {
// search vector output fields not exist, part exist
outputFields := []notExistOutputFields{[]string{"aaa"}, []string{"fields", common.DefaultFloatFieldName},
[]string{"fields", "*"}}
sp, _ := entity.NewIndexHNSWSearchParam(74)
_, errSearch := mc.Search(
ctx, collName,
[]string{},
"",
fields,
common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector),
common.DefaultFloatVecFieldName,
entity.L2,
common.DefaultTopK,
sp,
)
common.CheckErr(t, errSearch, false, "not exist")
for _, fields := range outputFields {
log.Println(fields)
_, errSearch := mc.Search(
ctx, collName,
[]string{},
"",
fields,
common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector),
common.DefaultFloatVecFieldName,
entity.L2,
common.DefaultTopK,
sp,
)
common.CheckErr(t, errSearch, true)
}
}
}

Expand Down