Skip to content

Commit 1f17caa

Browse files
authored
fix: Fix online pg import (feast-dev#4581)
* fix postgres import issue Signed-off-by: cmuhao <sduxuhao@gmail.com> * fix postgres import issue Signed-off-by: cmuhao <sduxuhao@gmail.com> * fix postgres import issue Signed-off-by: cmuhao <sduxuhao@gmail.com> * fix postgres import issue Signed-off-by: cmuhao <sduxuhao@gmail.com> * fix lint Signed-off-by: cmuhao <sduxuhao@gmail.com> --------- Signed-off-by: cmuhao <sduxuhao@gmail.com>
1 parent 8cd0dcf commit 1f17caa

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

sdk/python/feast/infra/online_stores/contrib/postgres.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
from feast import Entity
2424
from feast.feature_view import FeatureView
2525
from feast.infra.key_encoding_utils import get_list_val_str, serialize_entity_key
26-
from feast.infra.online_stores.contrib.singlestore_online_store.singlestore import (
27-
_to_naive_utc,
28-
)
26+
from feast.infra.online_stores.helpers import _to_naive_utc
2927
from feast.infra.online_stores.online_store import OnlineStore
3028
from feast.infra.utils.postgres.connection_utils import (
3129
_get_conn,

sdk/python/feast/infra/online_stores/contrib/singlestore_online_store/singlestore.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import absolute_import
22

33
from collections import defaultdict
4-
from datetime import datetime, timezone
4+
from datetime import datetime
55
from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple
66

77
import singlestoredb
@@ -11,6 +11,7 @@
1111

1212
from feast import Entity, FeatureView, RepoConfig
1313
from feast.infra.key_encoding_utils import serialize_entity_key
14+
from feast.infra.online_stores.helpers import _to_naive_utc
1415
from feast.infra.online_stores.online_store import OnlineStore
1516
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
1617
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
@@ -225,10 +226,3 @@ def _drop_table_and_index(cur: Cursor, project: str, table: FeatureView) -> None
225226

226227
def _table_id(project: str, table: FeatureView) -> str:
227228
return f"{project}_{table.name}"
228-
229-
230-
def _to_naive_utc(ts: datetime) -> datetime:
231-
if ts.tzinfo is None:
232-
return ts
233-
else:
234-
return ts.astimezone(tz=timezone.utc).replace(tzinfo=None)

sdk/python/feast/infra/online_stores/helpers.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import struct
2+
from datetime import datetime, timezone
23
from typing import Any, List
34

45
import mmh3
@@ -62,3 +63,10 @@ def compute_entity_id(
6263
entity_key_serialization_version=entity_key_serialization_version,
6364
)
6465
).hex()
66+
67+
68+
def _to_naive_utc(ts: datetime) -> datetime:
69+
if ts.tzinfo is None:
70+
return ts
71+
else:
72+
return ts.astimezone(tz=timezone.utc).replace(tzinfo=None)

0 commit comments

Comments
 (0)