From 9fee746e76bf3a908c79d0a99a121e2aa6f4ecdf Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 22 Oct 2018 17:41:59 -0500 Subject: [PATCH] translate column argument in Rows() query --- executor.go | 1 + executor_test.go | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/executor.go b/executor.go index c57f80618..82d2135ab 100644 --- a/executor.go +++ b/executor.go @@ -2166,6 +2166,7 @@ func (e *executor) translateCall(index string, idx *Index, c *pql.Call) error { case "Rows": fieldName = callArgString(c, "field") rowKey = "previous" + colKey = "column" case "GroupBy": return errors.Wrap(e.translateGroupByCall(index, idx, c), "translating GroupBy") default: diff --git a/executor_test.go b/executor_test.go index 311745c56..03b659f33 100644 --- a/executor_test.go +++ b/executor_test.go @@ -2678,7 +2678,7 @@ func TestExecutor_Execute_Rows_Keys(t *testing.T) { c := test.MustRunCluster(t, 1) defer c.Close() - _, err := c[0].API.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}) + _, err := c[0].API.CreateIndex(context.Background(), "i", pilosa.IndexOptions{Keys: true}) if err != nil { t.Fatalf("creating index: %v", err) } @@ -2695,7 +2695,7 @@ func TestExecutor_Execute_Rows_Keys(t *testing.T) { for shard := 0; shard < 10; shard++ { for i := shard; i < shard+10; i++ { for row := i; row >= 0 && row > i-3; row-- { - query.WriteString(fmt.Sprintf("Set(%d, f=\"%d\")", shard*pilosa.ShardWidth+i, row)) + query.WriteString(fmt.Sprintf("Set(\"%d\", f=\"%d\")", shard*pilosa.ShardWidth+i, row)) } @@ -2742,39 +2742,39 @@ func TestExecutor_Execute_Rows_Keys(t *testing.T) { exp: []string{}, }, { - q: `Rows(field=f, column=1)`, + q: `Rows(field=f, column="1")`, exp: []string{"0", "1"}, }, { - q: `Rows(field=f, column=2)`, + q: `Rows(field=f, column="2")`, exp: []string{"0", "1", "2"}, }, { - q: `Rows(field=f, column=3)`, + q: `Rows(field=f, column="3")`, exp: []string{"1", "2", "3"}, }, { - q: `Rows(field=f, limit=2, column=3)`, + q: `Rows(field=f, limit=2, column="3")`, exp: []string{"1", "2"}, }, { - q: fmt.Sprintf(`Rows(field=f, previous="15", column=%d)`, ShardWidth*9+17), + q: fmt.Sprintf(`Rows(field=f, previous="15", column="%d")`, ShardWidth*9+17), exp: []string{"16", "17"}, }, { - q: fmt.Sprintf(`Rows(field=f, previous="11", limit=2, column=%d)`, ShardWidth*5+14), + q: fmt.Sprintf(`Rows(field=f, previous="11", limit=2, column="%d")`, ShardWidth*5+14), exp: []string{"12", "13"}, }, { - q: fmt.Sprintf(`Rows(field=f, previous="17", limit=5, column=%d)`, ShardWidth*9+18), + q: fmt.Sprintf(`Rows(field=f, previous="17", limit=5, column="%d")`, ShardWidth*9+18), exp: []string{"18"}, }, { - q: `Rows(field=f, previous="18", column=19)`, + q: `Rows(field=f, previous="18", column="19")`, exp: []string{}, }, { - q: `Rows(field=f, previous="1", limit=0, column=0)`, + q: `Rows(field=f, previous="1", limit=0, column="0")`, exp: []string{}, }, }