Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ jobs:
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
- name: Install feast locally
run: make install-feast-locally
- name: Install the gcp extra for the Bigtable end-to-end test
run: uv pip install -e ".[gcp]"
- name: Run Go tests with coverage
run: |
# The Go packages share a registry fixture and must run sequentially.
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ repos:
.*\.lock|
.*requirements.*\.txt|
.*\.svg|
.*\.html
.*\.html|
go/internal/feast/onlinestore/testdata/bigtable_fixtures\.json
)$

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/feature-store-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ online_store:

* **provider** \("local" or "gcp"\) — Defines the environment in which Feast will execute data flows.
* **registry** \(a local or GCS filepath\) — Defines the location of the feature registry.
* **online\_store** — Configures the online store. This field will have various subfields depending on the type of online store:
* **online\_store** — Configures the online store. This field will have various subfields depending on the type of online store. Each store's page under [Online stores](online-stores/README.md) lists its options, for example the Bigtable read settings that only the Go feature server uses ([Bigtable](online-stores/bigtable.md#go-feature-server)). The sqlite and datastore options are:
* **type** \("sqlite" or "datastore"\) — Defines the type of online store.
* **path** \(a local filepath\) — Parameter for the sqlite online store. Defines the path to the SQLite database file.
* **project\_id** — Optional parameter for the datastore online store. Sets the GCP project id used by Feast, if not set Feast will use the default GCP project id in the local environment.
Expand Down
184 changes: 183 additions & 1 deletion docs/reference/online-stores/bigtable.md

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/feast-dev/feast
go 1.26.10

require (
cloud.google.com/go/bigtable v1.58.0
cloud.google.com/go/storage v1.71.0
github.com/apache/arrow/go/v17 v17.0.0
github.com/aws/aws-sdk-go-v2 v1.48.0
Expand All @@ -19,6 +20,7 @@ require (
github.com/mattn/go-sqlite3 v1.14.53
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.25.0
github.com/prometheus/client_model v0.6.3
github.com/redis/go-redis/v9 v9.23.0
github.com/roberson-io/mmh3 v0.0.0-20190729202758-fdfce3ba6225
github.com/rs/zerolog v1.35.1
Expand All @@ -29,7 +31,9 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0
go.opentelemetry.io/otel/sdk v1.47.0
go.opentelemetry.io/otel/trace v1.47.0
golang.org/x/oauth2 v0.38.0
golang.org/x/sync v0.25.0
google.golang.org/api v0.316.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f
google.golang.org/grpc v1.85.0
google.golang.org/protobuf v1.36.12
Expand All @@ -42,6 +46,7 @@ require (
cloud.google.com/go/auth/oauth2adapt v0.3.1 // indirect
cloud.google.com/go/compute/metadata v0.10.0 // indirect
cloud.google.com/go/iam v1.15.1 // indirect
cloud.google.com/go/longrunning v1.5.0 // indirect
cloud.google.com/go/monitoring v1.32.1 // indirect
filippo.io/edwards25519 v1.2.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.63.0 // indirect
Expand Down Expand Up @@ -77,6 +82,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.12.0 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v25.12.19+incompatible // indirect
github.com/google/s2a-go v0.1.11 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.25 // indirect
Expand All @@ -89,6 +95,7 @@ require (
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/klauspost/compress v1.20.5 // indirect
github.com/klauspost/cpuid/v2 v2.4.2 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.16 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
Expand All @@ -97,7 +104,6 @@ require (
github.com/pandatix/go-abnf v0.5.5 // indirect
github.com/pierrec/lz4/v4 v4.1.33 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.74.0 // indirect
github.com/prometheus/procfs v0.23.0 // indirect
github.com/spiffe/go-spiffe/v2 v2.9.0 // indirect
Expand All @@ -117,15 +123,14 @@ require (
golang.org/x/exp v0.0.0-20261120182113-8801fbdfac81 // indirect
golang.org/x/mod v0.43.0 // indirect
golang.org/x/net v0.63.0 // indirect
golang.org/x/oauth2 v0.38.0 // indirect
golang.org/x/sys v0.50.0 // indirect
golang.org/x/telemetry v0.0.0-20261119160235-508b12de1089 // indirect
golang.org/x/text v0.44.0 // indirect
golang.org/x/time v0.16.0 // indirect
golang.org/x/tools v0.53.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/api v0.316.0 // indirect
google.golang.org/genproto v0.0.0-20261118221215-c8830f628b3f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
rsc.io/binaryregexp v0.2.0 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cloud.google.com/go/auth v0.24.4 h1:m49juFKXOaeRwmLgcrd3e4hrwqLDe1+4g8fH0EoznUU=
cloud.google.com/go/auth v0.24.4/go.mod h1:p4UXqfSXnMVUDutk9xePzI8lj8yyoJ3BLsKWv0NSvQk=
cloud.google.com/go/auth/oauth2adapt v0.3.1 h1:BKLDdbWS7pafd820dsyFDF6fPEzIGqr7ny6hbTzCCgE=
cloud.google.com/go/auth/oauth2adapt v0.3.1/go.mod h1:B1nM4FJDxoDqAt3PXFG4IflUoQ5kvWAOOM3R+5wAszg=
cloud.google.com/go/bigtable v1.58.0 h1:fkf7bI0DBkKN85uRrfEEpkbufSc48b4PVIZCRud3xRk=
cloud.google.com/go/bigtable v1.58.0/go.mod h1:fZ/QM3mBog9JYJ5KV1z2xqv2+vfHGvoazGJllGQClds=
cloud.google.com/go/compute/metadata v0.10.0 h1:pyKMUQSwchgkIBBJGdILqQbs/BNJXqwSA7Ej6LAvvtY=
cloud.google.com/go/compute/metadata v0.10.0/go.mod h1:rGFHRrIif570kSibjFTMbt6/4/tzgJWFGI/HVol4GIk=
cloud.google.com/go/iam v1.15.1 h1:i6EXLKyIi0Sh72p+5+Fz0PfnzB63bkneVpaBCGrjlWs=
Expand Down Expand Up @@ -129,6 +131,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/google/flatbuffers v25.12.19+incompatible h1:haMV2JRRJCe1998HeW/p0X9UaMTK6SDo0ffLn2+DbLs=
github.com/google/flatbuffers v25.12.19+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
Expand Down Expand Up @@ -333,3 +337,5 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
12 changes: 8 additions & 4 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ The server exposes Prometheus metrics at the `/metrics` endpoint on a dedicated
Key metrics include:
- `http_request_duration_seconds`: Histogram of response latency.
- `http_requests_total`: Counter of HTTP requests by status, method, and path.
- `feast_bigtable_online_read_duration_seconds`, `feast_bigtable_online_read_chunks_total` and
`feast_bigtable_online_read_rows_found_total`: Bigtable online store reads, when that store is used
(see `docs/reference/online-stores/bigtable.md`).
- Standard Go and Process metrics.

A `/health` endpoint is available on the main application port (default `:8080`) for readiness probes.
Expand All @@ -35,10 +38,11 @@ The default exporter URL is "http://localhost:4318". The default schema of sendi
## List of files have OTEL observability code
1. internal/feast/transformation/transformation.go
2. internal/feast/onlinestore/redisonlinestore.go
3. internal/feast/server/grpc_server.go
4. internal/feast/server/http_server.go
5. internal/feast/server/server_commons.go
6. internal/feast/featurestore.go
3. internal/feast/onlinestore/bigtableonlinestore.go
4. internal/feast/server/grpc_server.go
5. internal/feast/server/http_server.go
6. internal/feast/server/server_commons.go
7. internal/feast/featurestore.go

## Example monitoring infra setup
1. docker compose file to setup Prometheus, Jaeger, and OTEL-collector.
Expand Down
24 changes: 23 additions & 1 deletion go/internal/feast/featurestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func NewFeatureStore(config *registry.RepoConfig, callback transformation.Transf
}, nil
}

// GetOnlineFeatures returns the requested features, named by featureRefs or by featureService, for the
// entity rows in joinKeyToEntityValues. It reads each group of feature views from the online store, then
// applies on-demand feature views using requestData.
//
// TODO: Review all functions that use ODFV and Request FV since these have not been tested
// ToDo: Split GetOnlineFeatures interface into two: GetOnlinFeaturesByFeatureService and GetOnlineFeaturesByFeatureRefs
func (fs *FeatureStore) GetOnlineFeatures(
Expand Down Expand Up @@ -168,7 +172,7 @@ func (fs *FeatureStore) GetOnlineFeatures(
}

for _, groupRef := range groupedRefs {
featureData, err := fs.readFromOnlineStore(ctx, groupRef.EntityKeys, groupRef.FeatureViewNames, groupRef.FeatureNames)
featureData, err := fs.readFromOnlineStore(ctx, groupRef.EntityKeys, groupRef.FeatureViewNames, groupRef.FeatureNames, requestedFeatureViews)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -320,9 +324,13 @@ func (fs *FeatureStore) GetFeatureView(featureViewName string, hideDummyEntity b
return fv, nil
}

// readFromOnlineStore reads one group of features from the online store. views is the request's own
// snapshot of its feature views (the one the entity keys were built from); stores that need entity names,
// such as Bigtable, get them from it, so a registry refresh mid-request cannot mix schemas.
func (fs *FeatureStore) readFromOnlineStore(ctx context.Context, entityRows []*prototypes.EntityKey,
requestedFeatureViewNames []string,
requestedFeatureNames []string,
views []*onlineserving.FeatureViewAndRefs,
) ([][]onlinestore.FeatureData, error) {
// Create a Datadog span from context
ctx, span := tracer.Start(ctx, "fs.readFromOnlineStore")
Expand All @@ -333,9 +341,23 @@ func (fs *FeatureStore) readFromOnlineStore(ctx context.Context, entityRows []*p
for index, entityKey := range entityRows {
entityRowsValue[index] = &prototypes.EntityKey{JoinKeys: entityKey.JoinKeys, EntityValues: entityKey.EntityValues}
}
if entityAwareStore, ok := fs.onlineStore.(onlinestore.EntityAwareOnlineStore); ok {
return entityAwareStore.OnlineReadWithEntities(ctx, entityRowsValue, requestedFeatureViewNames,
requestedFeatureNames, entityNamesByView(views))
}
return fs.onlineStore.OnlineRead(ctx, entityRowsValue, requestedFeatureViewNames, requestedFeatureNames)
}

// entityNamesByView maps each view's base name, which is the name GroupFeatureRefs passes to the online
// store, to its entity names. Projections of one view share a base name and its entities.
func entityNamesByView(views []*onlineserving.FeatureViewAndRefs) map[string][]string {
names := make(map[string][]string, len(views))
for _, viewAndRefs := range views {
names[viewAndRefs.View.Base.Name] = viewAndRefs.View.EntityNames
}
return names
}

func (fs *FeatureStore) GetFcosMap() (map[string]*model.Entity, map[string]*model.FeatureView, map[string]*model.OnDemandFeatureView, error) {
odfvs, err := fs.ListOnDemandFeatureViews()
if err != nil {
Expand Down
133 changes: 133 additions & 0 deletions go/internal/feast/featurestore_bigtable_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package feast

import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"testing"
"time"

"cloud.google.com/go/bigtable/bttest"
"github.com/apache/arrow/go/v17/arrow/array"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/feast-dev/feast/go/internal/feast/registry"
"github.com/feast-dev/feast/go/internal/test"
"github.com/feast-dev/feast/go/protos/feast/serving"
"github.com/feast-dev/feast/go/protos/feast/types"
)

// TestBigtablePythonMaterializeGoRead materializes the test feature repo into an in-memory Bigtable with
// the Python SDK's `feast apply` and `feast materialize-incremental`, then reads it back through
// FeatureStore.GetOnlineFeatures and the Go Bigtable store, and checks the values and event timestamps
// against the latest parquet row of each driver. It needs the `feast` CLI with the gcp extra
// (google-cloud-bigtable) and skips without it.
func TestBigtablePythonMaterializeGoRead(t *testing.T) {
if testing.Short() {
t.Skip("runs feast apply and materialize")
}
requireFeastWithBigtable(t)

srv, err := bttest.NewServer("localhost:0")
require.NoError(t, err)
t.Cleanup(srv.Close)
t.Setenv("BIGTABLE_EMULATOR_HOST", srv.Addr)

repoPath := newBigtableFeatureRepo(t)
runFeast(t, repoPath, "apply")
runFeast(t, repoPath, "materialize-incremental", time.Now().UTC().Format("2006-01-02T15:04:05"))

config, err := registry.NewRepoConfigFromFile(repoPath)
require.NoError(t, err)
fs, err := NewFeatureStore(config, nil)
require.NoError(t, err)
t.Cleanup(fs.onlineStore.Destruct)

const missingDriver = 9999
drivers := []int64{1001, 1002, 1003, missingDriver}
entityValues := make([]*types.Value, len(drivers))
for i, id := range drivers {
entityValues[i] = &types.Value{Val: &types.Value_Int64Val{Int64Val: id}}
}
vectors, err := fs.GetOnlineFeatures(context.Background(),
[]string{"driver_hourly_stats:conv_rate", "driver_hourly_stats:acc_rate", "driver_hourly_stats:avg_daily_trips"},
nil, map[string]*types.RepeatedValue{"driver_id": {Val: entityValues}}, nil, false)
require.NoError(t, err)

rows, err := test.ReadParquet(filepath.Join(featureRepoBasePath, "feature_repo", "driver_stats.parquet"))
require.NoError(t, err)
latest := test.GetLatestFeatures(rows, map[int64]bool{1001: true, 1002: true, 1003: true})

byName := make(map[string]int, len(vectors))
for i, v := range vectors {
byName[v.Name] = i
}
convRate := vectors[byName["conv_rate"]]
accRate := vectors[byName["acc_rate"]]
trips := vectors[byName["avg_daily_trips"]]
for i, id := range drivers {
if id == missingDriver {
assert.Equal(t, serving.FieldStatus_NOT_FOUND, convRate.Statuses[i], "driver %d", id)
continue
}
want := latest[id]
require.NotNil(t, want, "driver %d has no parquet row", id)
assert.Equal(t, serving.FieldStatus_PRESENT, convRate.Statuses[i], "driver %d", id)
assert.Equal(t, want.ConvRate, convRate.Values.(*array.Float32).Value(i), "driver %d conv_rate", id)
assert.Equal(t, want.AccRate, accRate.Values.(*array.Float32).Value(i), "driver %d acc_rate", id)
assert.Equal(t, int64(want.AvgDailyTrips), trips.Values.(*array.Int64).Value(i), "driver %d avg_daily_trips", id)
// ReadParquet returns driver_stats.parquet's raw microsecond timestamps (it reads them as arrow.Second).
assert.Equal(t, time.UnixMicro(want.EventTimestamp).Unix(), convRate.Timestamps[i].GetSeconds(), "driver %d event_ts", id)
}
}

// requireFeastWithBigtable skips the test unless the `feast` CLI is on PATH and the Python beside it can
// import google.cloud.bigtable (the gcp extra).
func requireFeastWithBigtable(t *testing.T) {
t.Helper()
feastPath, err := exec.LookPath("feast")
if err != nil {
t.Skip("needs the feast CLI on PATH")
}
python := filepath.Join(filepath.Dir(feastPath), "python")
if out, err := exec.Command(python, "-c", "import google.cloud.bigtable").CombinedOutput(); err != nil {
t.Skipf("needs the feast CLI with the gcp extra (google-cloud-bigtable): %v: %s", err, out)
}
}

// newBigtableFeatureRepo copies the test feature repo's definitions and data into a temporary repo whose
// online store is Bigtable on the emulator, and returns its path.
func newBigtableFeatureRepo(t *testing.T) string {
t.Helper()
repoPath := t.TempDir()
source := filepath.Join(featureRepoBasePath, "feature_repo")
for _, name := range []string{"__init__.py", "example.py", "driver_stats.parquet"} {
data, err := os.ReadFile(filepath.Join(source, name))
require.NoError(t, err)
require.NoError(t, os.WriteFile(filepath.Join(repoPath, name), data, 0o644))
}
yaml := `project: bigtable_e2e
registry: data/registry.db
provider: local
online_store:
type: bigtable
project_id: test-project
instance: test-instance
entity_key_serialization_version: 3
`
require.NoError(t, os.WriteFile(filepath.Join(repoPath, "feature_store.yaml"), []byte(yaml), 0o644))
return repoPath
}

// runFeast runs one feast CLI command in repoPath, with the test's environment (the emulator address).
func runFeast(t *testing.T, repoPath string, args ...string) {
t.Helper()
cmd := exec.Command("feast", args...)
cmd.Dir = repoPath
cmd.Env = os.Environ()
out, err := cmd.CombinedOutput()
require.NoError(t, err, fmt.Sprintf("feast %v: %s", args, out))
}
Loading
Loading