mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
add translation for groupby filter arg, improve test
This commit is contained in:
parent
de61d04172
commit
e185a01e67
2 changed files with 26 additions and 4 deletions
10
executor.go
10
executor.go
|
|
@ -2536,6 +2536,16 @@ func (e *executor) translateGroupByCall(index string, idx *Index, c *pql.Call) e
|
|||
}
|
||||
}
|
||||
|
||||
if filter, ok, err := c.CallArg("filter"); ok {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting filter call")
|
||||
}
|
||||
err = e.translateCall(index, idx, filter)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "translating filter call")
|
||||
}
|
||||
}
|
||||
|
||||
prev, ok := c.Args["previous"]
|
||||
if !ok {
|
||||
return nil // nothing else to be translated
|
||||
|
|
|
|||
|
|
@ -3262,23 +3262,35 @@ func TestExecutor_GroupByStrings(t *testing.T) {
|
|||
}
|
||||
|
||||
tests := []struct {
|
||||
query string
|
||||
query string
|
||||
expected []pilosa.GroupCount
|
||||
}{
|
||||
{
|
||||
query: "GroupBy(Rows(generals))",
|
||||
expected: []pilosa.GroupCount{
|
||||
{Group: []pilosa.FieldRow{{Field: "generals", RowID: 1, RowKey: "r1"}}, Count: 5},
|
||||
{Group: []pilosa.FieldRow{{Field: "generals", RowID: 2, RowKey: "r2"}}, Count: 5},
|
||||
},
|
||||
},
|
||||
{
|
||||
query: "GroupBy(Rows(generals), filter=Row(generals=r2))",
|
||||
expected: []pilosa.GroupCount{
|
||||
{Group: []pilosa.FieldRow{{Field: "generals", RowID: 2, RowKey: "r2"}}, Count: 5},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
for i, tst := range tests {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
r, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{
|
||||
Index: "istring",
|
||||
Query: test.query,
|
||||
Query: tst.query,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("got an error %v", err)
|
||||
}
|
||||
fmt.Println(r)
|
||||
results := r.Results[0].([]pilosa.GroupCount)
|
||||
test.CheckGroupBy(t, tst.expected, results)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue