Skip to content

Commit 7dda0b4

Browse files
committed
Fix Go
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent 523e021 commit 7dda0b4

7 files changed

+48
-31
lines changed

go/embedded/online_features.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (s *OnlineFeatureService) GetEntityTypesMap(featureRefs []string) (map[stri
8888
}
8989
for _, entityName := range view.Entities {
9090
entity := entitiesByName[entityName]
91-
joinKeyTypes[entity.JoinKey] = int32(entity.ValueType.Number())
91+
joinKeyTypes[entity.JoinKey] = int32(view.GetEntityType(entity.JoinKey).Number())
9292
}
9393
}
9494

@@ -117,7 +117,7 @@ func (s *OnlineFeatureService) GetEntityTypesMapByFeatureService(featureServiceN
117117
}
118118
for _, entityName := range view.Entities {
119119
entity := entitiesByName[entityName]
120-
joinKeyTypes[entity.JoinKey] = int32(entity.ValueType.Number())
120+
joinKeyTypes[entity.JoinKey] = int32(view.GetEntityType(entity.JoinKey).Number())
121121
}
122122
}
123123

go/internal/feast/featurestore.go

+1-1
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
}

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

+24-9
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ 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+
Entities []string
22+
EntityColumns []*Feature
2223
}
2324

2425
func NewFeatureViewFromProto(proto *core.FeatureView) *FeatureView {
@@ -30,23 +31,37 @@ func NewFeatureViewFromProto(proto *core.FeatureView) *FeatureView {
3031
} else {
3132
featureView.Entities = proto.Spec.Entities
3233
}
34+
entityColumns := make([]*Feature, len(proto.Spec.EntityColumns))
35+
for i, entityColumn := range proto.Spec.EntityColumns {
36+
entityColumns[i] = NewFeatureFromProto(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,
3945
Ttl: &ttl,
40-
Entities: fs.Entities,
46+
Entities: fv.Entities,
4147
}
4248
return featureView
4349
}
4450

45-
func (fs *FeatureView) HasEntity(lookup string) bool {
46-
for _, entityName := range fs.Entities {
51+
func (fv *FeatureView) HasEntity(lookup string) bool {
52+
for _, entityName := range fv.Entities {
4753
if entityName == lookup {
4854
return true
4955
}
5056
}
5157
return false
5258
}
59+
60+
func (fv *FeatureView) GetEntityType(lookup string) types.ValueType_Enum {
61+
for _, entityColumn := range fv.EntityColumns {
62+
if entityColumn.Name == lookup {
63+
return entityColumn.Dtype
64+
}
65+
}
66+
return types.ValueType_INVALID
67+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func generateSchema(featureService *model.FeatureService, entityMap map[string]*
6666
}
6767

6868
joinKeysSet[joinKey] = nil
69-
entityJoinKeyToType[joinKey] = entity.ValueType
69+
entityJoinKeyToType[joinKey] = fv.GetEntityType(entity.JoinKey)
7070
}
7171
} else if odFv, ok := odFvMap[featureViewName]; ok {
7272
for _, f := range featureProjection.Features {

go/internal/feast/server/logging/featureserviceschema_test.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ func InitializeFeatureRepoVariablesForTest() (*model.FeatureService, []*model.En
145145
[]*model.Feature{f1, f2},
146146
projection1,
147147
)
148-
featureView1 := test.CreateFeatureView(baseFeatureView1, nil, []string{"driver_id"})
149-
entity1 := test.CreateNewEntity("driver_id", types.ValueType_INT64, "driver_id")
148+
entity1 := test.CreateNewEntity("driver_id", "driver_id")
149+
entitycolumn1 := test.CreateNewFeature(
150+
"driver_id",
151+
types.ValueType_INT64,
152+
)
153+
featureView1 := test.CreateFeatureView(baseFeatureView1, nil, []string{"driver_id"}, []*model.Feature{entitycolumn1})
150154
f3 := test.CreateNewFeature(
151155
"int32",
152156
types.ValueType_INT32,
@@ -166,7 +170,7 @@ func InitializeFeatureRepoVariablesForTest() (*model.FeatureService, []*model.En
166170
[]*model.Feature{f3, f4},
167171
projection2,
168172
)
169-
featureView2 := test.CreateFeatureView(baseFeatureView2, nil, []string{"driver_id"})
173+
featureView2 := test.CreateFeatureView(baseFeatureView2, nil, []string{"driver_id"}, []*model.Feature{entitycolumn1})
170174

171175
f5 := test.CreateNewFeature(
172176
"odfv_f1",

go/internal/test/go_integration_test_utils.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@ func CreateBaseFeatureView(name string, features []*model.Feature, projection *m
201201
}
202202
}
203203

204-
func CreateNewEntity(name string, valueType types.ValueType_Enum, joinKey string) *model.Entity {
204+
func CreateNewEntity(name string, joinKey string) *model.Entity {
205205
return &model.Entity{
206-
Name: name,
207-
ValueType: valueType,
208-
JoinKey: joinKey,
206+
Name: name,
207+
JoinKey: joinKey,
209208
}
210209
}
211210

@@ -233,10 +232,11 @@ func CreateNewFeatureViewProjection(name string, nameAlias string, features []*m
233232
}
234233
}
235234

236-
func CreateFeatureView(base *model.BaseFeatureView, ttl *durationpb.Duration, entities []string) *model.FeatureView {
235+
func CreateFeatureView(base *model.BaseFeatureView, ttl *durationpb.Duration, entities []string, entityColumns []*model.Feature) *model.FeatureView {
237236
return &model.FeatureView{
238-
Base: base,
239-
Ttl: ttl,
240-
Entities: entities,
237+
Base: base,
238+
Ttl: ttl,
239+
Entities: entities,
240+
EntityColumns: entityColumns,
241241
}
242242
}

0 commit comments

Comments
 (0)