-
Notifications
You must be signed in to change notification settings - Fork 978
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix conversion of null timestamp from proto to python
Signed-off-by: Andrew Pope <apope@nursefly.com>
- Loading branch information
Andrew Pope
committed
Jun 17, 2022
1 parent
6b4e8d0
commit 02379aa
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,28 @@ | ||
import numpy as np | ||
|
||
from feast.type_map import ( | ||
feast_value_type_to_python_type, | ||
python_values_to_proto_values, | ||
) | ||
from feast.value_type import ValueType | ||
|
||
|
||
def test_null_unix_timestamp(): | ||
"""Test that null UnixTimestamps get converted from proto correctly.""" | ||
|
||
data = np.array(["NaT"], dtype="datetime64") | ||
protos = python_values_to_proto_values(data, ValueType.UNIX_TIMESTAMP) | ||
converted = feast_value_type_to_python_type(protos[0]) | ||
|
||
assert converted is None | ||
|
||
|
||
def test_null_unix_timestamp_list(): | ||
"""Test that UnixTimestamp lists with a null get converted from proto | ||
correctly.""" | ||
|
||
data = np.array([["NaT"]], dtype="datetime64") | ||
protos = python_values_to_proto_values(data, ValueType.UNIX_TIMESTAMP_LIST) | ||
converted = feast_value_type_to_python_type(protos[0]) | ||
|
||
assert converted[0] is None |