Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support INT32 type for entity keys #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

msistla96
Copy link
Collaborator

@msistla96 msistla96 commented Apr 30, 2024

What this PR does / why we need it:
Add support for INT32 type for entity keys. This is because there's a bug when using INT32 for entity values, where the feature server would return those values as null. This is because the JSON marshaling for these values are only supported for INT64.

Also add support for request sources to be specified in the request_context as well

Edit: We will need to update the Feature Definitions related documentation to be clear on the fact that we should pass entity join keys when retrieving features, not entities themselves and also use the request Context to pass their request sources.
Which issue(s) this PR fixes:

Fixes # https://jira.expedia.biz/browse/EAPC-11996

@msistla96 msistla96 changed the title EAPC 11996 fix: support INT32 type for entity keys Apr 30, 2024
@msistla96 msistla96 marked this pull request as ready for review May 2, 2024 21:02
go/internal/feast/server/http_server.go Outdated Show resolved Hide resolved
go/internal/feast/model/entity.go Outdated Show resolved Hide resolved
go/internal/feast/server/http_server.go Show resolved Hide resolved
go/internal/feast/server/http_server.go Outdated Show resolved Hide resolved
acevedosharp
acevedosharp previously approved these changes May 9, 2024
fvName, _, _ := onlineserving.ParseFeatureReference(featuresRequested)
_, err := fs.GetFeatureView(fvName, false)
if err != nil {
odfv, err := fs.GetOnDemandFeatureView(fvName)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When request has features from Feature view and ODFV, this logic fails the request. It's a valid case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code doesn't exist. I modified it to get request sources from on demand FVs only.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old comment.

@@ -32,10 +32,10 @@ type Registry struct {
project string
registryStore RegistryStore
cachedFeatureServices map[string]map[string]*core.FeatureService
cachedEntities map[string]map[string]*core.Entity
CachedEntities map[string]map[string]*core.Entity
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please revert the changes to this file?

if len(requestSources) > 0 {
return requestSources, nil
}
return nil, fmt.Errorf("Request sources for feature views %v not found", fVList)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ODFVs can exist without Request Sources.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that ODFVs will have sources other than request sources?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

}
entitiesProto[key] = value.ToProto()
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feast does support zero entities

fVList = append(fVList, fv.Name)
}
} else if request.Features != nil && len(request.Features) > 0 {
log.Info().Msgf("request.Features %v", request.Features)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this. This just logs for every request.

@@ -38,3 +39,11 @@ func TestUnmarshalJSON(t *testing.T) {
assert.Nil(t, u.UnmarshalJSON([]byte("[[true, false, true], [false, true, false]]")))
assert.Equal(t, [][]bool{{true, false, true}, {false, true, false}}, u.boolListVal)
}

func testTypecastToCorrectTypeWithInt32Val(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start with Capital T

@@ -1,6 +1,7 @@
package server

import (
prototypes "github.com/feast-dev/feast/go/protos/feast/types"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more tests for the logic added

}
}
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you refine logic, please check if the else logic is still needed.

Comment on lines +272 to +279
fieldType, ok1 := unifiedMap[key]
if ok1 {
typecastToEntitySchemaType(&value, fieldType)
} else {
logSpanContext.Error().Msgf("Entity type/request source type for key %s not found. Check if your join key names or request sources are correct", key)
writeJSONError(w, fmt.Errorf("Entity type/request source type for key %s not found. Check if your join key names or request sources are correct", key), http.StatusNotFound)
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fieldType, ok := unifiedMap[key]
if !ok {
// Error Logic
}
typecastToEntitySchemaType(&value, fieldType)

for key, value := range request.RequestContext {
requestContextProto[key] = value.ToProto()
if len(unifiedMap) > 0 {
if request.Entities != nil && len(request.Entities) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just use len(request.entities) > 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added that condition in to check for the map, but I guess if i'm checking the length of the entity it's probably not needed. I'll remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants