ensure ClearRow() arguments get translated

This commit is contained in:
Travis Turner 2019-01-29 12:36:54 -06:00
parent 988d5a6156
commit 30711664e8
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
2 changed files with 17 additions and 1 deletions

View file

@ -1693,6 +1693,9 @@ func (e *executor) executeClearRow(ctx context.Context, index string, c *pql.Cal
}
result, err := e.mapReduce(ctx, index, shards, c, opt, mapFn, reduceFn)
if err != nil {
return false, errors.Wrap(err, "mapreducing clearrow")
}
return result.(bool), err
}
@ -2368,7 +2371,7 @@ func (e *executor) translateCalls(ctx context.Context, index string, idx *Index,
func (e *executor) translateCall(index string, idx *Index, c *pql.Call) error {
var colKey, rowKey, fieldName string
switch c.Name {
case "Set", "Clear", "Row", "Range", "SetColumnAttrs":
case "Set", "Clear", "Row", "Range", "SetColumnAttrs", "ClearRow":
// Positional args in new PQL syntax require special handling here.
colKey = "_" + columnLabel
fieldName, _ = c.FieldArg()

View file

@ -2887,6 +2887,19 @@ func TestExecutor_Execute_ClearRow(t *testing.T) {
t.Fatalf("topn wrong results: %v", res.Results)
}
})
// Ensure that ClearRow returns false when the row to clear needs translation.
t.Run("WithKeys", func(t *testing.T) {
wq := ""
rq := []string{
`ClearRow(f="bar")`,
}
responses := runCallTest(t, wq, rq, &pilosa.IndexOptions{}, pilosa.OptFieldKeys())
if res := responses[0].Results[0].(bool); res {
t.Fatalf("unexpected result: %+v", res)
}
})
}
// Ensure a row can be set.