mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
handle missing index in join properly
This commit is contained in:
parent
3bb45ea2c0
commit
3140b2d8cb
2 changed files with 26 additions and 3 deletions
10
executor.go
10
executor.go
|
|
@ -3588,7 +3588,10 @@ func (e *executor) collectCallKeySets(ctx context.Context, indexName string, c *
|
|||
|
||||
// Collect foreign index keys.
|
||||
if fieldName != "" {
|
||||
idx := e.Holder.indexes[indexName]
|
||||
idx, exists := e.Holder.indexes[indexName]
|
||||
if !exists {
|
||||
return errors.Errorf("index %s does not exist", indexName)
|
||||
}
|
||||
if field := idx.Field(fieldName); field != nil && field.ForeignIndex() != "" {
|
||||
foreignIndexName := field.ForeignIndex()
|
||||
if m[foreignIndexName] == nil {
|
||||
|
|
@ -3633,7 +3636,10 @@ func (e *executor) translateCall(indexName string, c *pql.Call, keyMaps map[stri
|
|||
|
||||
// Translate column key.
|
||||
colKey, rowKey, fieldName := c.TranslateInfo(columnLabel, rowLabel)
|
||||
idx := e.Holder.indexes[indexName]
|
||||
idx, exists := e.Holder.indexes[indexName]
|
||||
if !exists {
|
||||
return errors.Errorf("index %s does not exist", indexName)
|
||||
}
|
||||
if idx.Keys() {
|
||||
if c.Args[colKey] != nil && !isString(c.Args[colKey]) {
|
||||
if !isValidID(c.Args[colKey]) {
|
||||
|
|
|
|||
|
|
@ -4415,7 +4415,6 @@ func runCallTest(t *testing.T, writeQuery string, readQueries []string, indexOpt
|
|||
|
||||
c := test.MustRunCluster(t, 1)
|
||||
defer c.Close()
|
||||
|
||||
hldr := test.Holder{Holder: c[0].Server.Holder()}
|
||||
index := hldr.MustCreateIndexIfNotExists("i", *indexOptions)
|
||||
_, err := index.CreateField("f", fieldOption...)
|
||||
|
|
@ -4717,3 +4716,21 @@ func TestExecutor_Execute_MinMaxCountEqual(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestExecutor_Execute_NoIndex(t *testing.T) {
|
||||
t.Helper()
|
||||
indexOptions := &pilosa.IndexOptions{}
|
||||
c := test.MustRunCluster(t, 1)
|
||||
defer c.Close()
|
||||
hldr := test.Holder{Holder: c[0].Server.Holder()}
|
||||
index := hldr.MustCreateIndexIfNotExists("i", *indexOptions)
|
||||
//_, err := index.CreateField("f", fieldOption...)
|
||||
index.CreateField("f")
|
||||
|
||||
if _, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{
|
||||
Index: "i",
|
||||
Query: "Count(Distinct(Row(gpu_tag='GTX'), index=systems, field=jarvis_id))",
|
||||
}); err == nil {
|
||||
t.Fatal("expecting error: 'index systems does not exist'")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue