Skip to content

Commit

Permalink
fix: Use updated error message and skip json invalid expr case
Browse files Browse the repository at this point in the history
See also milvus-io#675 milvus-io#674

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Mar 18, 2024
1 parent 1a1a092 commit bbb7f3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,8 @@ var InvalidExpressions = []InvalidExprStruct{
{Expr: "int64 in not [0]", ErrNil: false, ErrMsg: "cannot parse expression"}, // wrong term expr keyword
{Expr: "int64 < floatVec", ErrNil: false, ErrMsg: "not supported"}, // unsupported compare field
{Expr: "floatVec in [0]", ErrNil: false, ErrMsg: "cannot be casted to FloatVector"}, // value and field type mismatch
{Expr: fmt.Sprintf("%s == 1", DefaultJSONFieldName), ErrNil: false, ErrMsg: "can not comparisons jsonField directly"},
{Expr: fmt.Sprintf("%s == 1", DefaultDynamicFieldName), ErrNil: false, ErrMsg: "can not comparisons jsonField directly"},
// {Expr: fmt.Sprintf("%s == 1", DefaultJSONFieldName), ErrNil: false, ErrMsg: "can not comparisons jsonField directly"},
// {Expr: fmt.Sprintf("%s == 1", DefaultDynamicFieldName), ErrNil: false, ErrMsg: "can not comparisons jsonField directly"},
{Expr: fmt.Sprintf("%s[\"dynamicList\"] == [2, 3]", DefaultDynamicFieldName), ErrNil: true, ErrMsg: ""},
{Expr: fmt.Sprintf("%s['a'] == [2, 3]", DefaultJSONFieldName), ErrNil: true, ErrMsg: ""}, // json field not exist
{Expr: fmt.Sprintf("%s['number'] == [2, 3]", DefaultJSONFieldName), ErrNil: true, ErrMsg: ""}, // field exist but type not match
Expand Down
4 changes: 2 additions & 2 deletions test/testcases/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ func TestCreateCollectionInvalidDim(t *testing.T) {
}
invalidDims := []invalidDimStruct{
{dim: "10", errMsg: "should be multiple of 8"},
{dim: "0", errMsg: "should be in range 1 ~ 32768"},
{dim: "0", errMsg: "should be in range 2 ~ 32768"},
{dim: "", errMsg: "invalid syntax"},
{dim: "中文", errMsg: "invalid syntax"},
{dim: "%$#", errMsg: "invalid syntax"},
{dim: fmt.Sprintf("%d", common.MaxDim+1), errMsg: "should be in range 1 ~ 32768"},
{dim: fmt.Sprintf("%d", common.MaxDim+1), errMsg: "invalid dimension"},
}

// connect
Expand Down
8 changes: 4 additions & 4 deletions test/testcases/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestSearchCollectionNotExist(t *testing.T) {
common.DefaultTopK,
sp,
)
common.CheckErr(t, errSearch, false, "collection not found")
common.CheckErr(t, errSearch, false, "can't find collection")
}

// test search empty collection -> return empty
Expand Down Expand Up @@ -1230,7 +1230,7 @@ func TestRangeSearchScannL2(t *testing.T) {
sp.AddRangeFilter(20)
_, errRange := mc.Search(ctx, collName, []string{}, "", []string{"*"}, queryVec, common.DefaultFloatVecFieldName,
entity.L2, common.DefaultTopK, sp)
common.CheckErr(t, errRange, false, "range_filter(20) must be less than radius(15) for L2/HAMMING/JACCARD")
common.CheckErr(t, errRange, false, "range_filter must be less than radius")
}

// test range search with scann index and IP COSINE metric type
Expand Down Expand Up @@ -1289,7 +1289,7 @@ func TestRangeSearchScannIPCosine(t *testing.T) {
sp.AddRangeFilter(10)
_, errRange := mc.Search(ctx, collName, []string{}, "", []string{"*"}, queryVec, common.DefaultFloatVecFieldName,
metricType, common.DefaultTopK, sp)
common.CheckErr(t, errRange, false, "range_filter(10) must be greater than radius(20) for IP/COSINE")
common.CheckErr(t, errRange, false, "range_filter must be greater than radius")
}
}

Expand Down Expand Up @@ -1350,7 +1350,7 @@ func TestRangeSearchScannBinary(t *testing.T) {
sp.AddRangeFilter(100)
_, errRange := mc.Search(ctx, collName, []string{}, "", []string{"*"}, queryVec, common.DefaultBinaryVecFieldName,
metricType, common.DefaultTopK, sp)
common.CheckErr(t, errRange, false, "range_filter(100) must be less than radius(0) for L2/HAMMING/JACCARD")
common.CheckErr(t, errRange, false, "range_filter must be less than radius")
}
}

Expand Down

0 comments on commit bbb7f3b

Please sign in to comment.