Skip to content

Commit 5fea698

Browse files
YHC66ntkathole
authored andcommitted
fix: Avoid NumPy generic-unit deprecation when importing feast.type_map
Signed-off-by: Yihang Chen <[email protected]>
1 parent 0b03236 commit 5fea698

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎sdk/python/feast/type_map.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
import pyarrow
7070

7171
# null timestamps get converted to -9223372036854775808
72-
NULL_TIMESTAMP_INT_VALUE: int = np.datetime64("NaT").astype(int)
72+
NULL_TIMESTAMP_INT_VALUE: int = np.datetime64("NaT", "ns").astype(int)
7373

7474
logger = logging.getLogger(__name__)
7575

‎sdk/python/tests/unit/test_type_map.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import subprocess
2+
import sys
13
import uuid
24

35
import numpy as np
@@ -2340,3 +2342,26 @@ def test_not_supported_as_collection_base_type(self):
23402342
Array(ZonedTimestamp)
23412343
with pytest.raises(ValueError):
23422344
Set(ZonedTimestamp)
2345+
2346+
2347+
def test_import_does_not_emit_numpy_deprecation_warning():
2348+
# A unit-less np.datetime64("NaT") uses NumPy's deprecated "generic" unit,
2349+
# which would make importing feast fail under -W error::DeprecationWarning.
2350+
result = subprocess.run(
2351+
[
2352+
sys.executable,
2353+
"-W",
2354+
"error::DeprecationWarning:feast.type_map",
2355+
"-c",
2356+
"import feast.type_map",
2357+
],
2358+
capture_output=True,
2359+
text=True,
2360+
)
2361+
assert result.returncode == 0, result.stderr
2362+
2363+
2364+
def test_null_timestamp_int_value():
2365+
from feast.type_map import NULL_TIMESTAMP_INT_VALUE
2366+
2367+
assert NULL_TIMESTAMP_INT_VALUE == np.iinfo(np.int64).min

0 commit comments

Comments
 (0)