Skip to content

Commit

Permalink
fix: to just check null in group by field only (#37191)
Browse files Browse the repository at this point in the history
#37187

Signed-off-by: lixinguo <[email protected]>
Co-authored-by: lixinguo <[email protected]>
  • Loading branch information
smellthemoon and lixinguo authored Oct 29, 2024
1 parent 8894346 commit 86b9c3e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/proxy/search_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ func parseGroupByInfo(searchParamsPair []*commonpb.KeyValuePair, schema *schemap
if groupByFieldName != "" {
fields := schema.GetFields()
for _, field := range fields {
if field.GetNullable() {
ret.err = merr.WrapErrParameterInvalidMsg(fmt.Sprintf("groupBy field(%s) not support nullable == true", groupByFieldName))
return ret
}
if field.Name == groupByFieldName {
if field.GetNullable() {
ret.err = merr.WrapErrParameterInvalidMsg(fmt.Sprintf("groupBy field(%s) not support nullable == true", groupByFieldName))
return ret
}
groupByFieldId = field.FieldID
break
}
Expand Down
22 changes: 22 additions & 0 deletions internal/proxy/task_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,28 @@ func TestTaskSearch_parseSearchInfo(t *testing.T) {
searchInfo := parseSearchInfo(normalParam, schema, nil)
assert.Nil(t, searchInfo.planInfo)
assert.ErrorIs(t, searchInfo.parseError, merr.ErrParameterInvalid)

normalParam = getValidSearchParams()
normalParam = append(normalParam, &commonpb.KeyValuePair{
Key: GroupByFieldKey,
Value: "string_field",
})
fields = make([]*schemapb.FieldSchema, 0)
fields = append(fields, &schemapb.FieldSchema{
FieldID: int64(101),
Name: "string_field",
})
fields = append(fields, &schemapb.FieldSchema{
FieldID: int64(102),
Name: "null_field",
Nullable: true,
})
schema = &schemapb.CollectionSchema{
Fields: fields,
}
searchInfo = parseSearchInfo(normalParam, schema, nil)
assert.NotNil(t, searchInfo.planInfo)
assert.NoError(t, searchInfo.parseError)
})
t.Run("check iterator and topK", func(t *testing.T) {
normalParam := getValidSearchParams()
Expand Down

0 comments on commit 86b9c3e

Please sign in to comment.