diff --git a/executor.go b/executor.go index 2ec33902e..d0c53d43b 100644 --- a/executor.go +++ b/executor.go @@ -3590,7 +3590,7 @@ func (e *executor) collectCallKeySets(ctx context.Context, indexName string, c * if fieldName != "" { idx, exists := e.Holder.indexes[indexName] if !exists { - return errors.Errorf("index %s does not exist", indexName) + return errors.Wrapf(ErrIndexNotFound, "%s", indexName) } if field := idx.Field(fieldName); field != nil && field.ForeignIndex() != "" { foreignIndexName := field.ForeignIndex() @@ -3638,7 +3638,7 @@ func (e *executor) translateCall(indexName string, c *pql.Call, keyMaps map[stri colKey, rowKey, fieldName := c.TranslateInfo(columnLabel, rowLabel) idx, exists := e.Holder.indexes[indexName] if !exists { - return errors.Errorf("index %s does not exist", indexName) + return errors.Wrapf(ErrIndexNotFound, "%s", indexName) } if idx.Keys() { if c.Args[colKey] != nil && !isString(c.Args[colKey]) { diff --git a/executor_test.go b/executor_test.go index 7f7bfb956..5e969a977 100644 --- a/executor_test.go +++ b/executor_test.go @@ -4724,13 +4724,15 @@ func TestExecutor_Execute_NoIndex(t *testing.T) { defer c.Close() hldr := test.Holder{Holder: c[0].Server.Holder()} index := hldr.MustCreateIndexIfNotExists("i", *indexOptions) - //_, err := index.CreateField("f", fieldOption...) - index.CreateField("f") + _, err := index.CreateField("f") + if err != nil { + t.Fatal("should work") + } if _, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{ Index: "i", Query: "Count(Distinct(Row(gpu_tag='GTX'), index=systems, field=jarvis_id))", - }); err == nil { + }); errors.Cause(err) != pilosa.ErrIndexNotFound { t.Fatal("expecting error: 'index systems does not exist'") } }