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 BYTES and BYTES_LIST type conversion #2158

Merged
merged 1 commit into from
Dec 17, 2021
Merged
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
9 changes: 7 additions & 2 deletions sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import base64
import re
from datetime import datetime
from typing import Any, Dict, List, Optional, Set, Tuple, Type
Expand Down Expand Up @@ -62,15 +63,19 @@ def feast_value_type_to_python_type(field_value_proto: ProtoValue) -> Any:
if k == "int64Val":
return int(val)
if k == "bytesVal":
return bytes(val)
# MessageToDict converts the bytes object to base64 encoded string:
# https://developers.google.com/protocol-buffers/docs/proto3#json
return base64.b64decode(val)
if (k == "int64ListVal") or (k == "int32ListVal"):
return [int(item) for item in val]
if (k == "floatListVal") or (k == "doubleListVal"):
return [float(item) for item in val]
if k == "stringListVal":
return [str(item) for item in val]
if k == "bytesListVal":
return [bytes(item) for item in val]
# MessageToDict converts the bytes object to base64 encoded string:
# https://developers.google.com/protocol-buffers/docs/proto3#json
return [base64.b64decode(val) for item in val]
if k == "boolListVal":
return [bool(item) for item in val]

Expand Down