mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
fix find & create foreign index keys
This commit is contained in:
parent
a6e3723190
commit
1fe0edae08
1 changed files with 18 additions and 17 deletions
35
executor.go
35
executor.go
|
|
@ -4827,8 +4827,10 @@ func (e *executor) preTranslate(ctx context.Context, index string, calls ...*pql
|
|||
}
|
||||
}
|
||||
|
||||
// Translate columns.
|
||||
// Create keys.
|
||||
// Both rows and columns need to be created first because of foreign index keys.
|
||||
cols = make(map[string]map[string]uint64)
|
||||
rows = make(map[string]map[string]map[string]uint64)
|
||||
for idx, keys := range collector.createCols {
|
||||
translations, err := e.Cluster.createIndexKeys(ctx, index, keys...)
|
||||
if err != nil {
|
||||
|
|
@ -4836,22 +4838,6 @@ func (e *executor) preTranslate(ctx context.Context, index string, calls ...*pql
|
|||
}
|
||||
cols[idx] = translations
|
||||
}
|
||||
for idx, keys := range collector.findCols {
|
||||
translations, err := e.Cluster.findIndexKeys(ctx, index, keys...)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "finding query column keys")
|
||||
}
|
||||
if prev := cols[idx]; prev != nil {
|
||||
for key, id := range translations {
|
||||
prev[key] = id
|
||||
}
|
||||
} else {
|
||||
cols[idx] = translations
|
||||
}
|
||||
}
|
||||
|
||||
// Translate rows.
|
||||
rows = make(map[string]map[string]map[string]uint64)
|
||||
for idx, fields := range collector.createRows {
|
||||
idxRows := make(map[string]map[string]uint64)
|
||||
index := e.Holder.Index(idx)
|
||||
|
|
@ -4871,6 +4857,21 @@ func (e *executor) preTranslate(ctx context.Context, index string, calls ...*pql
|
|||
}
|
||||
rows[idx] = idxRows
|
||||
}
|
||||
|
||||
// Find other keys.
|
||||
for idx, keys := range collector.findCols {
|
||||
translations, err := e.Cluster.findIndexKeys(ctx, index, keys...)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "finding query column keys")
|
||||
}
|
||||
if prev := cols[idx]; prev != nil {
|
||||
for key, id := range translations {
|
||||
prev[key] = id
|
||||
}
|
||||
} else {
|
||||
cols[idx] = translations
|
||||
}
|
||||
}
|
||||
for idx, fields := range collector.findRows {
|
||||
idxRows := rows[idx]
|
||||
if idxRows == nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue