FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Null value compatibility for unit timestamp list value type by EXPEbdodla · Pull Request #4378 · feast-dev/feast · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
17 changes: 11 additions & 6 deletions sdk/python/feast/type_map.py
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
Expand Up @@ -396,13 +396,18 @@ def _python_value_to_proto_value(
raise _type_err(item, valid_types[0])

if feast_value_type == ValueType.UNIX_TIMESTAMP_LIST:
int_timestamps_lists = (
_python_datetime_to_int_timestamp(value) for value in values
)
return [
# ProtoValue does actually accept `np.int_` but the typing complains.
ProtoValue(unix_timestamp_list_val=Int64List(val=ts)) # type: ignore
for ts in int_timestamps_lists
(
# ProtoValue does actually accept `np.int_` but the typing complains.
ProtoValue(
unix_timestamp_list_val=Int64List(
val=_python_datetime_to_int_timestamp(value) # type: ignore
)
)
if value is not None
else ProtoValue()
)
for value in values
]
if feast_value_type == ValueType.BOOL_LIST:
# ProtoValue does not support conversion of np.bool_ so we need to convert it to support np.bool_.
Expand Down
7 changes: 7 additions & 0 deletions sdk/python/tests/unit/test_type_map.py
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
Expand Up @@ -60,7 +60,14 @@ def test_python_values_to_proto_values_bool(values):
(np.array([b'["a","b","c"]']), ValueType.STRING_LIST, ["a", "b", "c"]),
(np.array([b"[true,false]"]), ValueType.BOOL_LIST, [True, False]),
(np.array([b"[1,0]"]), ValueType.BOOL_LIST, [True, False]),
(np.array([None]), ValueType.INT32_LIST, None),
(np.array([None]), ValueType.INT64_LIST, None),
(np.array([None]), ValueType.FLOAT_LIST, None),
(np.array([None]), ValueType.DOUBLE_LIST, None),
(np.array([None]), ValueType.BOOL_LIST, None),
(np.array([None]), ValueType.BYTES_LIST, None),
(np.array([None]), ValueType.STRING_LIST, None),
(np.array([None]), ValueType.UNIX_TIMESTAMP_LIST, None),
([b"[1,2,3]"], ValueType.INT64_LIST, [1, 2, 3]),
([b"[1,2,3]"], ValueType.INT32_LIST, [1, 2, 3]),
([b"[1.5,2.5,3.5]"], ValueType.FLOAT_LIST, [1.5, 2.5, 3.5]),
Expand Down

Back | FazBrowse Home | New Git URL