fix: to just check null in group by field only (#37191)

#37187

Signed-off-by: lixinguo <xinguo.li@zilliz.com>
Co-authored-by: lixinguo <xinguo.li@zilliz.com>
This commit is contained in:
smellthemoon 2024-10-29 15:38:30 +08:00 committed by GitHub
parent 889434691c
commit 86b9c3ef4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 4 deletions

View File

@ -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
}

View File

@ -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()