Fix GroupBy Distinct aggregate on int field

This commit is contained in:
Cody Soyland 2021-01-08 13:35:46 -06:00
parent 55fad52c59
commit 83ce30f1c4
No known key found for this signature in database
GPG key ID: 6F5D2986DCC5DC8A
2 changed files with 15 additions and 1 deletions

View file

@ -2829,7 +2829,12 @@ func (e *executor) executeGroupBy(ctx context.Context, qcx *Qcx, index string, c
for n, gc := range results {
intersectRows := make([]*pql.Call, 0, len(gc.Group))
for _, fr := range gc.Group {
intersectRows = append(intersectRows, &pql.Call{Name: "Row", Args: map[string]interface{}{fr.Field: fr.RowID}})
var value interface{} = fr.RowID
// use fr.Value instead of fr.RowID if set (from int fields)
if fr.Value != nil {
value = &pql.Condition{Op: pql.EQ, Value: *fr.Value}
}
intersectRows = append(intersectRows, &pql.Call{Name: "Row", Args: map[string]interface{}{fr.Field: value}})
}
// apply any filter, if present
if filter != nil {

View file

@ -7108,6 +7108,15 @@ toucan,1,10000
csvVerifier: `toucan,1,10000
zebra,1,1000
pangolin,1,100
`,
},
{
query: "GroupBy(Rows(field=affinity), aggregate=Count(Distinct(field=zip_code)))",
csvVerifier: `-10,1,1
-5,1,1
0,1,1
5,1,1
10,1,1
`,
},
}