mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Merge pull request #36 from travisturner/includescolumn-keys
Add column keys support to IncludeColumn
This commit is contained in:
commit
4dfeb89b43
2 changed files with 44 additions and 1 deletions
|
|
@ -3120,6 +3120,8 @@ func (e *executor) translateCall(index string, idx *Index, c *pql.Call) error {
|
|||
colKey = "column"
|
||||
case "GroupBy":
|
||||
return errors.Wrap(e.translateGroupByCall(index, idx, c), "translating GroupBy")
|
||||
case "IncludesColumn":
|
||||
colKey = "column"
|
||||
default:
|
||||
colKey = "col"
|
||||
fieldName = callArgString(c, "field")
|
||||
|
|
|
|||
|
|
@ -4092,7 +4092,7 @@ func TestExecutor_Execute_Shift(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExecutor_Execute_IncludesColumn(t *testing.T) {
|
||||
t.Run("results", func(t *testing.T) {
|
||||
t.Run("results-ids", func(t *testing.T) {
|
||||
c := test.MustRunCluster(t, 1)
|
||||
defer c.Close()
|
||||
hldr := test.Holder{Holder: c[0].Server.Holder()}
|
||||
|
|
@ -4122,6 +4122,47 @@ func TestExecutor_Execute_IncludesColumn(t *testing.T) {
|
|||
})
|
||||
}
|
||||
})
|
||||
t.Run("results-keys", func(t *testing.T) {
|
||||
c := test.MustRunCluster(t, 1)
|
||||
defer c.Close()
|
||||
cmd := c[0]
|
||||
hldr := test.Holder{Holder: c[0].Server.Holder()}
|
||||
index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{Keys: true})
|
||||
if _, err := index.CreateField("general", pilosa.OptFieldTypeDefault(), pilosa.OptFieldKeys()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := cmd.API.Query(
|
||||
context.Background(),
|
||||
&pilosa.QueryRequest{
|
||||
Index: "i",
|
||||
Query: `Set("one", general="ten") Set("eleven", general="ten") Set("twentyone", general="ten")`,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for i, tt := range []struct {
|
||||
col string
|
||||
expIncluded bool
|
||||
}{
|
||||
{"one", true},
|
||||
{"two", false},
|
||||
{"eleven", true},
|
||||
{"twelve", false},
|
||||
{"twentyone", true},
|
||||
{"twentytwo", false},
|
||||
} {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
if res, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: fmt.Sprintf("IncludesColumn(Row(general=ten), column=%s)", tt.col)}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if tt.expIncluded && !res.Results[0].(bool) {
|
||||
t.Fatalf("expected to find column: %s", tt.col)
|
||||
} else if !tt.expIncluded && res.Results[0].(bool) {
|
||||
t.Fatalf("did not expect to find column: %s", tt.col)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
t.Run("errors", func(t *testing.T) {
|
||||
c := test.MustRunCluster(t, 1)
|
||||
defer c.Close()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue