Skip to content

Commit 737c488

Browse files
chore: Deprecate value type (feast-dev#2611)
* Switch `entities` from List[str] to List[Entity] Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Remove `value_type` from SDK Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Remove `value_type` from tests Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Deprecate `value_type` parameter for Entity Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Add fields for entities to avoid type inference after removing `value_type` Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Go Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix type inference Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Another fix Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Another fix Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Rename Entities to EntityNames in go Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Rename lookup Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Rename Feature to Field Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Clean up inference Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Refactor Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Use old `value_type` attribute if it still exists Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Refactor Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Add TODO Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent cef4d3c commit 737c488

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+583
-540
lines changed

examples/java-demo/feature_repo/driver_repo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from google.protobuf.duration_pb2 import Duration
88
from feast.field import Field
99

10-
from feast import Entity, Feature, BatchFeatureView, FileSource, ValueType
10+
from feast import Entity, Feature, BatchFeatureView, FileSource
1111

1212
driver_hourly_stats = FileSource(
1313
path="data/driver_stats_with_string.parquet",
1414
timestamp_field="event_timestamp",
1515
created_timestamp_column="created",
1616
)
17-
driver = Entity(name="driver_id", value_type=ValueType.INT64, description="driver id",)
17+
driver = Entity(name="driver_id", description="driver id",)
1818
driver_hourly_stats_view = BatchFeatureView(
1919
name="driver_hourly_stats",
2020
entities=["driver_id"],

go/embedded/online_features.go

+4-18
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ func (s *OnlineFeatureService) GetEntityTypesMap(featureRefs []string) (map[stri
8080
viewNames[viewName] = nil
8181
}
8282

83-
entities, _ := s.fs.ListEntities(true)
84-
entitiesByName := make(map[string]*model.Entity)
85-
for _, entity := range entities {
86-
entitiesByName[entity.Name] = entity
87-
}
88-
8983
joinKeyTypes := make(map[string]int32)
9084

9185
for viewName := range viewNames {
@@ -94,9 +88,8 @@ func (s *OnlineFeatureService) GetEntityTypesMap(featureRefs []string) (map[stri
9488
// skip on demand feature views
9589
continue
9690
}
97-
for _, entityName := range view.Entities {
98-
entity := entitiesByName[entityName]
99-
joinKeyTypes[entity.JoinKey] = int32(entity.ValueType.Number())
91+
for _, entityColumn := range view.EntityColumns {
92+
joinKeyTypes[entityColumn.Name] = int32(entityColumn.Dtype.Number())
10093
}
10194
}
10295

@@ -111,21 +104,14 @@ func (s *OnlineFeatureService) GetEntityTypesMapByFeatureService(featureServiceN
111104

112105
joinKeyTypes := make(map[string]int32)
113106

114-
entities, _ := s.fs.ListEntities(true)
115-
entitiesByName := make(map[string]*model.Entity)
116-
for _, entity := range entities {
117-
entitiesByName[entity.Name] = entity
118-
}
119-
120107
for _, projection := range featureService.Projections {
121108
view, err := s.fs.GetFeatureView(projection.Name, true)
122109
if err != nil {
123110
// skip on demand feature views
124111
continue
125112
}
126-
for _, entityName := range view.Entities {
127-
entity := entitiesByName[entityName]
128-
joinKeyTypes[entity.JoinKey] = int32(entity.ValueType.Number())
113+
for _, entityColumn := range view.EntityColumns {
114+
joinKeyTypes[entityColumn.Name] = int32(entityColumn.Dtype.Number())
129115
}
130116
}
131117

go/internal/feast/featurestore.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (fs *FeatureStore) GetOnlineFeatures(
132132
if entitylessCase {
133133
dummyEntityColumn := &prototypes.RepeatedValue{Val: make([]*prototypes.Value, numRows)}
134134
for index := 0; index < numRows; index++ {
135-
dummyEntityColumn.Val[index] = &model.DUMMY_ENTITY
135+
dummyEntityColumn.Val[index] = &model.DUMMY_ENTITY_VALUE
136136
}
137137
joinKeyToEntityValues[model.DUMMY_ENTITY_ID] = dummyEntityColumn
138138
}
@@ -272,7 +272,7 @@ func (fs *FeatureStore) GetFeatureView(featureViewName string, hideDummyEntity b
272272
return nil, err
273273
}
274274
if fv.HasEntity(model.DUMMY_ENTITY_NAME) && hideDummyEntity {
275-
fv.Entities = []string{}
275+
fv.EntityNames = []string{}
276276
}
277277
return fv, nil
278278
}

go/internal/feast/model/basefeatureview.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import (
88

99
type BaseFeatureView struct {
1010
Name string
11-
Features []*Feature
11+
Features []*Field
1212
Projection *FeatureViewProjection
1313
}
1414

1515
func NewBaseFeatureView(name string, featureProtos []*core.FeatureSpecV2) *BaseFeatureView {
1616
base := &BaseFeatureView{Name: name}
17-
features := make([]*Feature, len(featureProtos))
17+
features := make([]*Field, len(featureProtos))
1818
for index, featureSpecV2 := range featureProtos {
19-
features[index] = NewFeatureFromProto(featureSpecV2)
19+
features[index] = NewFieldFromProto(featureSpecV2)
2020
}
2121
base.Features = features
2222
base.Projection = NewFeatureViewProjectionFromDefinition(base)
@@ -43,7 +43,7 @@ func (fv *BaseFeatureView) WithProjection(projection *FeatureViewProjection) (*B
4343
}
4444

4545
func (fv *BaseFeatureView) ProjectWithFeatures(featureNames []string) *FeatureViewProjection {
46-
features := make([]*Feature, 0)
46+
features := make([]*Field, 0)
4747
for _, feature := range fv.Features {
4848
for _, allowedFeatureName := range featureNames {
4949
if feature.Name == allowedFeatureName {

go/internal/feast/model/entity.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ package model
22

33
import (
44
"github.com/feast-dev/feast/go/protos/feast/core"
5-
"github.com/feast-dev/feast/go/protos/feast/types"
65
)
76

87
type Entity struct {
9-
Name string
10-
ValueType types.ValueType_Enum
11-
JoinKey string
8+
Name string
9+
JoinKey string
1210
}
1311

1412
func NewEntityFromProto(proto *core.Entity) *Entity {
15-
return &Entity{Name: proto.Spec.Name,
16-
ValueType: proto.Spec.ValueType,
17-
JoinKey: proto.Spec.JoinKey,
13+
return &Entity{
14+
Name: proto.Spec.Name,
15+
JoinKey: proto.Spec.JoinKey,
1816
}
1917
}

go/internal/feast/model/featureview.go

+19-13
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,44 @@ const (
1313
DUMMY_ENTITY_VAL = ""
1414
)
1515

16-
var DUMMY_ENTITY types.Value = types.Value{Val: &types.Value_StringVal{StringVal: DUMMY_ENTITY_VAL}}
16+
var DUMMY_ENTITY_VALUE types.Value = types.Value{Val: &types.Value_StringVal{StringVal: DUMMY_ENTITY_VAL}}
1717

1818
type FeatureView struct {
19-
Base *BaseFeatureView
20-
Ttl *durationpb.Duration
21-
Entities []string
19+
Base *BaseFeatureView
20+
Ttl *durationpb.Duration
21+
EntityNames []string
22+
EntityColumns []*Field
2223
}
2324

2425
func NewFeatureViewFromProto(proto *core.FeatureView) *FeatureView {
2526
featureView := &FeatureView{Base: NewBaseFeatureView(proto.Spec.Name, proto.Spec.Features),
2627
Ttl: &(*proto.Spec.Ttl),
2728
}
2829
if len(proto.Spec.Entities) == 0 {
29-
featureView.Entities = []string{DUMMY_ENTITY_NAME}
30+
featureView.EntityNames = []string{DUMMY_ENTITY_NAME}
3031
} else {
31-
featureView.Entities = proto.Spec.Entities
32+
featureView.EntityNames = proto.Spec.Entities
3233
}
34+
entityColumns := make([]*Field, len(proto.Spec.EntityColumns))
35+
for i, entityColumn := range proto.Spec.EntityColumns {
36+
entityColumns[i] = NewFieldFromProto(entityColumn)
37+
}
38+
featureView.EntityColumns = entityColumns
3339
return featureView
3440
}
3541

36-
func (fs *FeatureView) NewFeatureViewFromBase(base *BaseFeatureView) *FeatureView {
37-
ttl := durationpb.Duration{Seconds: fs.Ttl.Seconds, Nanos: fs.Ttl.Nanos}
42+
func (fv *FeatureView) NewFeatureViewFromBase(base *BaseFeatureView) *FeatureView {
43+
ttl := durationpb.Duration{Seconds: fv.Ttl.Seconds, Nanos: fv.Ttl.Nanos}
3844
featureView := &FeatureView{Base: base,
39-
Ttl: &ttl,
40-
Entities: fs.Entities,
45+
Ttl: &ttl,
46+
EntityNames: fv.EntityNames,
4147
}
4248
return featureView
4349
}
4450

45-
func (fs *FeatureView) HasEntity(lookup string) bool {
46-
for _, entityName := range fs.Entities {
47-
if entityName == lookup {
51+
func (fv *FeatureView) HasEntity(name string) bool {
52+
for _, entityName := range fv.EntityNames {
53+
if entityName == name {
4854
return true
4955
}
5056
}

go/internal/feast/model/featureviewprojection.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
type FeatureViewProjection struct {
88
Name string
99
NameAlias string
10-
Features []*Feature
10+
Features []*Field
1111
JoinKeyMap map[string]string
1212
}
1313

@@ -24,9 +24,9 @@ func NewFeatureViewProjectionFromProto(proto *core.FeatureViewProjection) *Featu
2424
JoinKeyMap: proto.JoinKeyMap,
2525
}
2626

27-
features := make([]*Feature, len(proto.FeatureColumns))
27+
features := make([]*Field, len(proto.FeatureColumns))
2828
for index, featureSpecV2 := range proto.FeatureColumns {
29-
features[index] = NewFeatureFromProto(featureSpecV2)
29+
features[index] = NewFieldFromProto(featureSpecV2)
3030
}
3131
featureProjection.Features = features
3232
return featureProjection

go/internal/feast/model/feature.go go/internal/feast/model/field.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"github.com/feast-dev/feast/go/protos/feast/types"
66
)
77

8-
type Feature struct {
8+
type Field struct {
99
Name string
1010
Dtype types.ValueType_Enum
1111
}
1212

13-
func NewFeatureFromProto(proto *core.FeatureSpecV2) *Feature {
14-
return &Feature{Name: proto.Name,
13+
func NewFieldFromProto(proto *core.FeatureSpecV2) *Field {
14+
return &Field{
15+
Name: proto.Name,
1516
Dtype: proto.ValueType,
1617
}
1718
}

go/internal/feast/onlineserving/serving.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func GetEntityMaps(requestedFeatureViews []*FeatureViewAndRefs, entities []*mode
251251
joinKeyToAliasMap = map[string]string{}
252252
}
253253

254-
for _, entityName := range featureView.Entities {
254+
for _, entityName := range featureView.EntityNames {
255255
joinKey := entitiesByName[entityName].JoinKey
256256
entityNameToJoinKeyMap[entityName] = joinKey
257257

@@ -518,7 +518,7 @@ func GroupFeatureRefs(requestedFeatureViews []*FeatureViewAndRefs,
518518
joinKeys := make([]string, 0)
519519
fv := featuresAndView.View
520520
featureNames := featuresAndView.FeatureRefs
521-
for _, entityName := range fv.Entities {
521+
for _, entityName := range fv.EntityNames {
522522
joinKeys = append(joinKeys, entityNameToJoinKeyMap[entityName])
523523
}
524524

go/internal/feast/onlineserving/serving_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ func TestGroupingFeatureRefs(t *testing.T) {
2020
NameAlias: "aliasViewA",
2121
},
2222
},
23-
Entities: []string{"driver", "customer"},
23+
EntityNames: []string{"driver", "customer"},
2424
}
2525
viewB := &model.FeatureView{
26-
Base: &model.BaseFeatureView{Name: "viewB"},
27-
Entities: []string{"driver", "customer"},
26+
Base: &model.BaseFeatureView{Name: "viewB"},
27+
EntityNames: []string{"driver", "customer"},
2828
}
2929
viewC := &model.FeatureView{
30-
Base: &model.BaseFeatureView{Name: "viewC"},
31-
Entities: []string{"driver"},
30+
Base: &model.BaseFeatureView{Name: "viewC"},
31+
EntityNames: []string{"driver"},
3232
}
3333
viewD := &model.FeatureView{
34-
Base: &model.BaseFeatureView{Name: "viewD"},
35-
Entities: []string{"customer"},
34+
Base: &model.BaseFeatureView{Name: "viewD"},
35+
EntityNames: []string{"customer"},
3636
}
3737
refGroups, _ := GroupFeatureRefs(
3838
[]*FeatureViewAndRefs{
@@ -105,11 +105,11 @@ func TestGroupingFeatureRefsWithJoinKeyAliases(t *testing.T) {
105105
JoinKeyMap: map[string]string{"location_id": "destination_id"},
106106
},
107107
},
108-
Entities: []string{"location"},
108+
EntityNames: []string{"location"},
109109
}
110110
viewB := &model.FeatureView{
111-
Base: &model.BaseFeatureView{Name: "viewB"},
112-
Entities: []string{"location"},
111+
Base: &model.BaseFeatureView{Name: "viewB"},
112+
EntityNames: []string{"location"},
113113
}
114114

115115
refGroups, _ := GroupFeatureRefs(
@@ -164,7 +164,7 @@ func TestGroupingFeatureRefsWithMissingKey(t *testing.T) {
164164
JoinKeyMap: map[string]string{"location_id": "destination_id"},
165165
},
166166
},
167-
Entities: []string{"location"},
167+
EntityNames: []string{"location"},
168168
}
169169

170170
_, err := GroupFeatureRefs(

go/internal/feast/server/logging/featureserviceschema.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,20 @@ func generateSchema(featureService *model.FeatureService, entityMap map[string]*
5252
features = append(features, fullFeatureName)
5353
allFeatureTypes[fullFeatureName] = f.Dtype
5454
}
55-
for _, entityName := range fv.Entities {
56-
entity := entityMap[entityName]
55+
for _, entityColumn := range fv.EntityColumns {
5756
var joinKey string
58-
if joinKeyAlias, ok := featureProjection.JoinKeyMap[entity.JoinKey]; ok {
57+
if joinKeyAlias, ok := featureProjection.JoinKeyMap[entityColumn.Name]; ok {
5958
joinKey = joinKeyAlias
6059
} else {
61-
joinKey = entity.JoinKey
60+
joinKey = entityColumn.Name
6261
}
6362

6463
if _, ok := joinKeysSet[joinKey]; !ok {
6564
joinKeys = append(joinKeys, joinKey)
6665
}
6766

6867
joinKeysSet[joinKey] = nil
69-
entityJoinKeyToType[joinKey] = entity.ValueType
68+
entityJoinKeyToType[joinKey] = entityColumn.Dtype
7069
}
7170
} else if odFv, ok := odFvMap[featureViewName]; ok {
7271
for _, f := range featureProjection.Features {

0 commit comments

Comments
 (0)