-
Notifications
You must be signed in to change notification settings - Fork 1.3k
chore: Use Go-based implementation as embedded extension to Python SDK #2429
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8961766
work in progress
pyalex 8b03be6
more supported type for proto <-> arrow converstion
pyalex 47cae14
better names
pyalex 70bdf1a
fix arrow to proto conversion
pyalex d14eeb2
fix import
pyalex 6ed2a2a
address some PR comments
pyalex dfd3a98
fix Makefile
pyalex ba40a15
type conversion test
pyalex 167c07a
rename package utils -> types
pyalex 5f97c4b
clean up on renaming
pyalex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
type conversion test
Signed-off-by: pyalex <moskalenko.alexey@gmail.com>
- Loading branch information
commit ba40a153db7db6318872df843f274686dc740499
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package utils | ||
|
|
||
| import ( | ||
| "github.com/apache/arrow/go/arrow/memory" | ||
| "github.com/feast-dev/feast/go/protos/feast/types" | ||
| "github.com/golang/protobuf/proto" | ||
| "github.com/stretchr/testify/assert" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| var ( | ||
| PROTO_VALUES = [][]*types.Value{ | ||
| {{Val: &types.Value_Int32Val{10}}, {Val: &types.Value_Int32Val{20}}}, | ||
| {{Val: &types.Value_Int64Val{10}}, {Val: &types.Value_Int64Val{20}}}, | ||
| {{Val: &types.Value_FloatVal{1.0}}, {Val: &types.Value_FloatVal{2.0}}}, | ||
| {{Val: &types.Value_DoubleVal{1.0}}, {Val: &types.Value_DoubleVal{2.0}}}, | ||
| {{Val: &types.Value_StringVal{"aaa"}}, {Val: &types.Value_StringVal{"bbb"}}}, | ||
| {{Val: &types.Value_BytesVal{[]byte{1, 2, 3}}}, {Val: &types.Value_BytesVal{[]byte{4, 5, 6}}}}, | ||
| {{Val: &types.Value_BoolVal{true}}, {Val: &types.Value_BoolVal{false}}}, | ||
| {{Val: &types.Value_UnixTimestampVal{time.Now().Unix()}}, | ||
| {Val: &types.Value_UnixTimestampVal{time.Now().Unix()}}}, | ||
|
|
||
| { | ||
| {Val: &types.Value_Int32ListVal{&types.Int32List{Val: []int32{0, 1, 2}}}}, | ||
| {Val: &types.Value_Int32ListVal{&types.Int32List{Val: []int32{3, 4, 5}}}}, | ||
| }, | ||
| { | ||
| {Val: &types.Value_Int64ListVal{&types.Int64List{Val: []int64{0, 1, 2}}}}, | ||
| {Val: &types.Value_Int64ListVal{&types.Int64List{Val: []int64{3, 4, 5}}}}, | ||
| }, | ||
| { | ||
| {Val: &types.Value_FloatListVal{&types.FloatList{Val: []float32{0.5, 1.5, 2}}}}, | ||
| {Val: &types.Value_FloatListVal{&types.FloatList{Val: []float32{3.5, 4, 5}}}}, | ||
| }, | ||
| { | ||
| {Val: &types.Value_DoubleListVal{&types.DoubleList{Val: []float64{0.5, 1, 2}}}}, | ||
| {Val: &types.Value_DoubleListVal{&types.DoubleList{Val: []float64{3.5, 4, 5}}}}, | ||
| }, | ||
| { | ||
| {Val: &types.Value_BytesListVal{&types.BytesList{Val: [][]byte{{0, 1}, {2}}}}}, | ||
| {Val: &types.Value_BytesListVal{&types.BytesList{Val: [][]byte{{3, 4}, {5}}}}}, | ||
| }, | ||
| { | ||
| {Val: &types.Value_StringListVal{&types.StringList{Val: []string{"aa", "bb"}}}}, | ||
| {Val: &types.Value_StringListVal{&types.StringList{Val: []string{"cc", "dd"}}}}, | ||
| }, | ||
| { | ||
| {Val: &types.Value_BoolListVal{&types.BoolList{Val: []bool{false, false}}}}, | ||
| {Val: &types.Value_BoolListVal{&types.BoolList{Val: []bool{true, true}}}}, | ||
| }, | ||
| { | ||
| {Val: &types.Value_UnixTimestampListVal{&types.Int64List{Val: []int64{time.Now().Unix()}}}}, | ||
| {Val: &types.Value_UnixTimestampListVal{&types.Int64List{Val: []int64{time.Now().Unix()}}}}, | ||
| }, | ||
| } | ||
| ) | ||
|
|
||
| func TestConversionBetweenProtoAndArrow(t *testing.T) { | ||
| pool := memory.NewGoAllocator() | ||
| for _, vector := range PROTO_VALUES { | ||
| arrowArray, err := ProtoValuesToArrowArray(vector, pool, len(vector)) | ||
| assert.Nil(t, err) | ||
|
|
||
| protoValues, err := ArrowValuesToProtoValues(arrowArray) | ||
| assert.Nil(t, err) | ||
|
|
||
| protoValuesEquals(t, vector, protoValues) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| func protoValuesEquals(t *testing.T, a, b []*types.Value) { | ||
| assert.Equal(t, len(a), len(b)) | ||
|
|
||
| for idx, left := range a { | ||
| assert.Truef(t, proto.Equal(left, b[idx]), | ||
| "Arrays are not equal. Diff[%d] %v != %v", idx, left, b[idx]) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, can we have a different module name instead of
utils? Seems like it'll become a kitchen sink..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed into
typessince it's type utils