Merge pull request #921 from niaow/fix-rows-type-error

Generate errors for all unsupported types in Rows calls
This commit is contained in:
Nia 2020-10-05 16:32:37 -04:00 committed by GitHub
commit 84830d8361
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View file

@ -2592,10 +2592,8 @@ func (e *executor) executeRowsShard(ctx context.Context, qcx *Qcx, index string,
// in order to represent `Rows` for the field.
var views = []string{viewStandard}
// Handle `int` and `time` fields.
switch f.Type() {
case FieldTypeInt:
return nil, errors.New("int fields not supported by Rows() query")
case FieldTypeSet, FieldTypeMutex:
case FieldTypeTime:
var err error
@ -2657,6 +2655,8 @@ func (e *executor) executeRowsShard(ctx context.Context, qcx *Qcx, index string,
// Determine the views based on the specified time range.
views = viewsByTimeRange(viewStandard, fromTime, toTime, q)
}
default:
return nil, errors.Errorf("%s fields not supported by Rows() query", f.Type())
}
start := uint64(0)

View file

@ -4851,6 +4851,8 @@ func TestExecutor_Execute_Query_Error(t *testing.T) {
defer c.Close()
c.CreateField(t, "i", pilosa.IndexOptions{}, "general")
c.CreateField(t, "i", pilosa.IndexOptions{}, "integer", pilosa.OptFieldTypeInt(-1000, 1000))
c.CreateField(t, "i", pilosa.IndexOptions{}, "decimal", pilosa.OptFieldTypeDecimal(2))
c.CreateField(t, "i", pilosa.IndexOptions{}, "bool", pilosa.OptFieldTypeBool())
tests := []struct {
query string
@ -4884,6 +4886,18 @@ func TestExecutor_Execute_Query_Error(t *testing.T) {
query: "GroupBy(Rows(integer), prev=-1)",
error: "unknown arg 'prev'",
},
{
query: "Rows(integer)",
error: "int fields not supported by Rows() query",
},
{
query: "Rows(decimal)",
error: "decimal fields not supported by Rows() query",
},
{
query: "Rows(bool)",
error: "bool fields not supported by Rows() query",
},
}
for i, test := range tests {