Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: Deduplicate feature view queries and fix index mapping
Signed-off-by: samuelkim7 <samuel.kim@goflink.com>
  • Loading branch information
samuelkim7 committed Feb 11, 2026
commit a9b803d3ca699539b99c7c640058e618e62282dc
35 changes: 23 additions & 12 deletions go/internal/feast/onlinestore/postgresonlinestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/url"
"strings"
"time"

"github.com/feast-dev/feast/go/internal/feast/registry"
Expand Down Expand Up @@ -65,14 +66,25 @@ func (p *PostgresOnlineStore) OnlineRead(ctx context.Context, entityKeys []*type
entityKeyMap[string(*serKey)] = i
}

featureNamesToIdx := make(map[string]int, len(featureNames))
for idx, name := range featureNames {
featureNamesToIdx[name] = idx
type featureRef struct {
name string
index int
}
featuresByView := make(map[string][]featureRef)
for i, viewName := range featureViewNames {
featuresByView[viewName] = append(featuresByView[viewName], featureRef{
name: featureNames[i],
index: i,
})
}

for _, featureViewName := range featureViewNames {
tableName := fmt.Sprintf(`"%s"`, strings.ReplaceAll(tableId(p.project, featureViewName), `"`, `""`))
for viewName, features := range featuresByView {
featureNamesToIdx := make(map[string]int, len(features))
for _, f := range features {
featureNamesToIdx[f.name] = f.index
}

tableName := fmt.Sprintf(`"%s"`, strings.ReplaceAll(tableId(p.project, viewName), `"`, `""`))
query := fmt.Sprintf(
`SELECT entity_key, feature_name, value, event_ts FROM %s WHERE entity_key = ANY($1)`,
tableName,
Expand Down Expand Up @@ -111,17 +123,16 @@ func (p *PostgresOnlineStore) OnlineRead(ctx context.Context, entityKeys []*type
}

results[rowIdx][featureIdx] = FeatureData{
Reference: serving.FeatureReferenceV2{FeatureViewName: featureViewName, FeatureName: featureName},
Reference: serving.FeatureReferenceV2{FeatureViewName: viewName, FeatureName: featureName},
Timestamp: *timestamppb.New(eventTs),
Value: types.Value{Val: value.Val},
}
}
}
rows.Close()
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("error iterating postgres rows: %w", err)
}

}
rows.Close()
Comment thread
samuelkim7 marked this conversation as resolved.
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("error iterating postgres rows: %w", err)
}
}

return results, nil
Expand Down
Loading