diff --git a/internal/proxy/count_reducer.go b/internal/proxy/count_reducer.go index 41a476ab99..90d1cb9137 100644 --- a/internal/proxy/count_reducer.go +++ b/internal/proxy/count_reducer.go @@ -6,7 +6,9 @@ import ( "github.com/milvus-io/milvus/internal/util/funcutil" ) -type cntReducer struct{} +type cntReducer struct { + collectionName string +} func (r *cntReducer) Reduce(results []*internalpb.RetrieveResults) (*milvuspb.QueryResults, error) { cnt := int64(0) @@ -17,5 +19,7 @@ func (r *cntReducer) Reduce(results []*internalpb.RetrieveResults) (*milvuspb.Qu } cnt += c } - return funcutil.WrapCntToQueryResults(cnt), nil + res := funcutil.WrapCntToQueryResults(cnt) + res.CollectionName = r.collectionName + return res, nil } diff --git a/internal/proxy/reducer.go b/internal/proxy/reducer.go index e1a9697d26..3821047e51 100644 --- a/internal/proxy/reducer.go +++ b/internal/proxy/reducer.go @@ -15,7 +15,9 @@ type milvusReducer interface { func createMilvusReducer(ctx context.Context, params *queryParams, req *internalpb.RetrieveRequest, schema *schemapb.CollectionSchema, plan *planpb.PlanNode, collectionName string) milvusReducer { if plan.GetQuery().GetIsCount() { - return &cntReducer{} + return &cntReducer{ + collectionName: collectionName, + } } return newDefaultLimitReducer(ctx, params, req, schema, collectionName) } diff --git a/internal/proxy/task_query.go b/internal/proxy/task_query.go index 8e6a0bec76..45f15ac72b 100644 --- a/internal/proxy/task_query.go +++ b/internal/proxy/task_query.go @@ -207,6 +207,7 @@ func (t *queryTask) createPlan(ctx context.Context) error { if cntMatch { var err error t.plan, err = createCntPlan(t.request.GetExpr(), schema) + t.userOutputFields = []string{"count(*)"} return err }