mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 11:27:50 +00:00
GroupBy legacy Rows
This commit is contained in:
parent
ca7dc073ab
commit
773d661b68
2 changed files with 24 additions and 3 deletions
13
executor.go
13
executor.go
|
|
@ -1090,7 +1090,8 @@ func (e *executor) executeGroupByShard(ctx context.Context, index string, c *pql
|
|||
|
||||
func (e *executor) executeRows(ctx context.Context, index string, c *pql.Call, shards []uint64, opt *execOptions) (RowIDs, error) {
|
||||
// Fetch field name from argument.
|
||||
// Check "field" first for backwards compatibility
|
||||
// Check "field" first for backwards compatibility.
|
||||
// TODO: remove at Pilosa 2.0
|
||||
var fieldName string
|
||||
var ok bool
|
||||
if fieldName, ok = c.Args["field"].(string); ok {
|
||||
|
|
@ -2763,10 +2764,16 @@ func newGroupByIterator(rowIDs []RowIDs, children []*pql.Call, filter *Row, inde
|
|||
fields: make([]FieldRow, len(children)),
|
||||
}
|
||||
|
||||
var fieldName string
|
||||
var ok bool
|
||||
ignorePrev := false
|
||||
for i, call := range children {
|
||||
fieldName, ok := call.Args["_field"].(string)
|
||||
if !ok {
|
||||
// Check "field" first for backwards compatibility.
|
||||
// TODO: remove at Pilosa 2.0
|
||||
if fieldName, ok = call.Args["field"].(string); ok {
|
||||
call.Args["_field"] = fieldName
|
||||
}
|
||||
if fieldName, ok = call.Args["_field"].(string); !ok {
|
||||
return nil, errors.Errorf("%s call must have field with valid (string) field name. Got %v of type %[2]T", call.Name, call.Args["_field"])
|
||||
}
|
||||
if holder.Field(index, fieldName) == nil {
|
||||
|
|
|
|||
|
|
@ -3300,6 +3300,20 @@ func TestExecutor_Execute_GroupBy(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
// backwards compatibility
|
||||
// TODO: remove at Pilosa 2.0
|
||||
t.Run("BasicLegacy", func(t *testing.T) {
|
||||
expected := []pilosa.GroupCount{
|
||||
{Group: []pilosa.FieldRow{{Field: "general", RowID: 10}, {Field: "sub", RowID: 100}}, Count: 3},
|
||||
{Group: []pilosa.FieldRow{{Field: "general", RowID: 10}, {Field: "sub", RowID: 110}}, Count: 1},
|
||||
{Group: []pilosa.FieldRow{{Field: "general", RowID: 11}, {Field: "sub", RowID: 110}}, Count: 1},
|
||||
{Group: []pilosa.FieldRow{{Field: "general", RowID: 12}, {Field: "sub", RowID: 110}}, Count: 1},
|
||||
}
|
||||
|
||||
results := c.Query(t, "i", `GroupBy(Rows(field=general), Rows(sub))`).Results[0].([]pilosa.GroupCount)
|
||||
test.CheckGroupBy(t, expected, results)
|
||||
})
|
||||
|
||||
t.Run("Basic", func(t *testing.T) {
|
||||
expected := []pilosa.GroupCount{
|
||||
{Group: []pilosa.FieldRow{{Field: "general", RowID: 10}, {Field: "sub", RowID: 100}}, Count: 3},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue