Merge branch 'master' into todo-503

This commit is contained in:
Kuba Podgórski 2020-07-01 16:23:38 +02:00 committed by GitHub
commit f0abb5e8b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View file

@ -699,7 +699,12 @@ func (e *executor) executeIncludesColumnCall(ctx context.Context, index string,
func (e *executor) executeFieldValueCall(ctx context.Context, index string, c *pql.Call, shards []uint64, opt *execOptions) (ValCount, error) {
fieldName, ok := c.Args["field"].(string)
if !ok || fieldName == "" {
return ValCount{}, errors.New("FieldValue(): field required")
return ValCount{}, ErrFieldRequired
}
colKey, ok := c.Args["column"]
if !ok || colKey == "" {
return ValCount{}, ErrColumnRequired
}
// Fetch index.
@ -715,8 +720,8 @@ func (e *executor) executeFieldValueCall(ctx context.Context, index string, c *p
}
var colID uint64
if colKey, ok := c.Args["column"].(string); ok && idx.Keys() {
id, err := e.Cluster.translateIndexKey(ctx, index, colKey)
if key, ok := colKey.(string); ok && idx.Keys() {
id, err := e.Cluster.translateIndexKey(ctx, index, key)
if err != nil {
return ValCount{}, errors.Wrap(err, "getting column id")
}

View file

@ -3522,7 +3522,6 @@ func TestExecutor_Execute_Not(t *testing.T) {
func TestExecutor_Execute_FieldValue(t *testing.T) {
c := test.MustRunCluster(t, 2)
defer c.Close()
//hldr := test.Holder{Holder: c[0].Server.Holder()}
node0 := c[0]
node1 := c[1]
@ -3535,8 +3534,8 @@ func TestExecutor_Execute_FieldValue(t *testing.T) {
Set(1, f=3)
Set(2, f=-4)
Set(` + strconv.Itoa(ShardWidth+1) + `, f=3)
Set(1, dec=12.985)
Set(2, dec=-4.234)
Set(1, dec=12.985)
Set(2, dec=-4.234)
`}); err != nil {
t.Fatal(err)
}
@ -3548,8 +3547,8 @@ func TestExecutor_Execute_FieldValue(t *testing.T) {
if _, err := node0.API.Query(context.Background(), &pilosa.QueryRequest{Index: "ik", Query: `
Set("one", f=3)
Set("two", f=-4)
Set("one", dec=12.985)
Set("two", dec=-4.234)
Set("one", dec=12.985)
Set("two", dec=-4.234)
`}); err != nil {
t.Fatal(err)
}
@ -3577,6 +3576,8 @@ func TestExecutor_Execute_FieldValue(t *testing.T) {
// Errors
{index: "i", qry: "FieldValue()", expErr: pilosa.ErrFieldRequired.Error()},
{index: "i", qry: "FieldValue(field=dec)", expErr: pilosa.ErrColumnRequired.Error()},
{index: "ik", qry: "FieldValue(field=f)", expErr: pilosa.ErrColumnRequired.Error()},
}
for n, node := range []*test.Command{node0, node1} {
for i, test := range tests {

View file

@ -33,9 +33,10 @@ var (
ErrForeignIndexNotFound = errors.New("foreign index not found")
// ErrFieldRequired is returned when no field is specified.
ErrFieldRequired = errors.New("field required")
ErrFieldExists = errors.New("field already exists")
ErrFieldNotFound = errors.New("field not found")
ErrFieldRequired = errors.New("field required")
ErrColumnRequired = errors.New("column required")
ErrFieldExists = errors.New("field already exists")
ErrFieldNotFound = errors.New("field not found")
ErrBSIGroupNotFound = errors.New("bsigroup not found")
ErrBSIGroupExists = errors.New("bsigroup already exists")