From 86b9c3ef4a4925289cc1039d2bd1bfb7c8cd75b7 Mon Sep 17 00:00:00 2001 From: smellthemoon <64083300+smellthemoon@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:38:30 +0800 Subject: [PATCH] fix: to just check null in group by field only (#37191) #37187 Signed-off-by: lixinguo Co-authored-by: lixinguo --- internal/proxy/search_util.go | 8 ++++---- internal/proxy/task_search_test.go | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/internal/proxy/search_util.go b/internal/proxy/search_util.go index 2d873a23dafca..3eab95cb2675a 100644 --- a/internal/proxy/search_util.go +++ b/internal/proxy/search_util.go @@ -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 } diff --git a/internal/proxy/task_search_test.go b/internal/proxy/task_search_test.go index c0cbbeefc659a..5b5e618a2f6be 100644 --- a/internal/proxy/task_search_test.go +++ b/internal/proxy/task_search_test.go @@ -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()