From 44f53a5f1de9af5793e1017b12ae4b510fa9cb75 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 14 Jan 2019 16:14:27 -0600 Subject: [PATCH 1/2] raise an error on Rows() query against a time field with noStandardView:true --- executor.go | 8 ++++++++ executor_test.go | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/executor.go b/executor.go index f68fec726..dffb0702e 100644 --- a/executor.go +++ b/executor.go @@ -1138,6 +1138,14 @@ func (e *executor) executeRowsShard(_ context.Context, index string, c *pql.Call if f == nil { return nil, ErrFieldNotFound } + + // Rows query does not currently support a `time` field that has + // `noStandardView: true`. + // TODO https://github.com/pilosa/pilosa/issues/1783 + if f.Type() == FieldTypeTime && f.options.NoStandardView { + return nil, errors.New("Rows() query on time field with no standard view is not supported") + } + frag := e.Holder.fragment(index, fieldName, viewStandard, shard) if frag == nil { return make(RowIDs, 0), nil diff --git a/executor_test.go b/executor_test.go index 0d42af8c5..950dc40a1 100644 --- a/executor_test.go +++ b/executor_test.go @@ -3059,6 +3059,17 @@ func TestExecutor_Execute_Rows(t *testing.T) { } } +func TestExecutor_Execute_RowsTime(t *testing.T) { + c := test.MustRunCluster(t, 1) + defer c.Close() + c.CreateField(t, "i", pilosa.IndexOptions{}, "t", pilosa.OptFieldTypeTime(pilosa.TimeQuantum("YMD"), true)) + + exp := "executing: Rows() query on time field with no standard view is not supported" + if _, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Rows(field=t)`}); err == nil || err.Error() != exp { + t.Fatalf("expected error: %s", exp) + } +} + func TestExecutor_Execute_Query_Error(t *testing.T) { c := test.MustRunCluster(t, 1) defer c.Close() From 6f21eb32de0d7d2924cabbda292d20fd59f4bab3 Mon Sep 17 00:00:00 2001 From: Matthew Jaffee Date: Thu, 17 Jan 2019 14:47:35 -0600 Subject: [PATCH 2/2] Apply suggestions from code review Co-Authored-By: travisturner --- executor.go | 2 +- executor_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/executor.go b/executor.go index dffb0702e..940120ec5 100644 --- a/executor.go +++ b/executor.go @@ -1143,7 +1143,7 @@ func (e *executor) executeRowsShard(_ context.Context, index string, c *pql.Call // `noStandardView: true`. // TODO https://github.com/pilosa/pilosa/issues/1783 if f.Type() == FieldTypeTime && f.options.NoStandardView { - return nil, errors.New("Rows() query on time field with no standard view is not supported") + return nil, errors.New("Rows() query on time field with no standard view is not currently supported") } frag := e.Holder.fragment(index, fieldName, viewStandard, shard) diff --git a/executor_test.go b/executor_test.go index 950dc40a1..3716e625f 100644 --- a/executor_test.go +++ b/executor_test.go @@ -3064,7 +3064,7 @@ func TestExecutor_Execute_RowsTime(t *testing.T) { defer c.Close() c.CreateField(t, "i", pilosa.IndexOptions{}, "t", pilosa.OptFieldTypeTime(pilosa.TimeQuantum("YMD"), true)) - exp := "executing: Rows() query on time field with no standard view is not supported" + exp := "executing: Rows() query on time field with no standard view is not currently supported" if _, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Rows(field=t)`}); err == nil || err.Error() != exp { t.Fatalf("expected error: %s", exp) }