diff --git a/executor.go b/executor.go index afea60112..4e2705b00 100644 --- a/executor.go +++ b/executor.go @@ -1059,6 +1059,16 @@ func (e *executor) executeClearBitField(ctx context.Context, index string, c *pq // executeSet executes a Set() call. func (e *executor) executeSet(ctx context.Context, index string, c *pql.Call, opt *execOptions) (bool, error) { + + // Read colID. + colID, ok, err := c.UintArg("_" + columnLabel) + if err != nil { + return false, fmt.Errorf("reading Set() column: %v", err) + } else if !ok { + return false, fmt.Errorf("Set() column argument '%v' required", columnLabel) + } + + // Read field name. fieldName, err := c.FieldArg() if err != nil { return false, errors.New("Set() argument required: field") @@ -1074,14 +1084,6 @@ func (e *executor) executeSet(ctx context.Context, index string, c *pql.Call, op return false, ErrFieldNotFound } - // Read colID using labels. - colID, ok, err := c.UintArg("_" + columnLabel) - if err != nil { - return false, fmt.Errorf("reading Set() column: %v", err) - } else if !ok { - return false, fmt.Errorf("Set() column argument '%v' required", columnLabel) - } - if f.Type() == FieldTypeInt { // Read remaining fields using labels. rowVal, ok, err := c.IntArg(fieldName) @@ -1575,7 +1577,11 @@ func (e *executor) translateCall(index string, idx *Index, c *pql.Call) error { if fieldName != "" { field := idx.Field(fieldName) if field == nil { - return ErrFieldNotFound + // Instead of returning ErrFieldNotFound here, + // we just return, and don't attempt the translation. + // The assumption is that the non-existant field + // will raise an error downstream when it's used. + return nil } if field.keys() { if c.Args[rowKey] != nil && !isString(c.Args[rowKey]) { diff --git a/executor_test.go b/executor_test.go index 41341b814..6e01f111f 100644 --- a/executor_test.go +++ b/executor_test.go @@ -440,7 +440,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { } t.Run("ErrColumnBSIGroupRequired", func(t *testing.T) { - if _, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Set(invalid_column_name=10, f=100)`}); err == nil || errors.Cause(err).Error() != `field not found` { + if _, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Set(invalid_column_name=10, f=100)`}); err == nil || errors.Cause(err).Error() != `Set() column argument 'col' required` { t.Fatalf("unexpected error: %s", err) } })