Skip to content

Commit

Permalink
Fix BYTES and BYTES_LIST type conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Judah Rand <17158624+judahrand@users.noreply.github.com>
  • Loading branch information
judahrand committed Dec 17, 2021
1 parent 90b8426 commit 25ec81b
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 25ec81b

Please sign in to comment.