Visitar URL original
fix: Fix online pg import by haoxu0 · Pull Request #4581 · feast-dev/feast · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix postgres import issue
Signed-off-by: cmuhao <sduxuhao@gmail.com>
  • Loading branch information
haoxu0 committed Sep 27, 2024
commit 8e6a9aecf750e54efd3d5369d6841aa9312f916e
4 changes: 1 addition & 3 deletions sdk/python/feast/infra/online_stores/contrib/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
from feast import Entity
from feast.feature_view import FeatureView
from feast.infra.key_encoding_utils import get_list_val_str, serialize_entity_key
from feast.infra.online_stores.contrib.singlestore_online_store.singlestore import (
_to_naive_utc,
)
from feast.infra.online_stores.helpers import _to_naive_utc
from feast.infra.online_stores.online_store import OnlineStore
from feast.infra.utils.postgres.connection_utils import (
_get_conn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.repo_config import FeastConfigBaseModel
from feast.infra.online_stores.helpers import _to_naive_utc


class SingleStoreOnlineStoreConfig(FeastConfigBaseModel):
Expand Down Expand Up @@ -226,9 +227,3 @@ def _drop_table_and_index(cur: Cursor, project: str, table: FeatureView) -> None
def _table_id(project: str, table: FeatureView) -> str:
return f"{project}_{table.name}"


def _to_naive_utc(ts: datetime) -> datetime:
if ts.tzinfo is None:
return ts
else:
return ts.astimezone(tz=timezone.utc).replace(tzinfo=None)
7 changes: 7 additions & 0 deletions sdk/python/feast/infra/online_stores/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ def compute_entity_id(
entity_key_serialization_version=entity_key_serialization_version,
)
).hex()


def _to_naive_utc(ts: datetime) -> datetime:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to set a defalt timezone instead of a none?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, i didn't implement it but just moved it out to helper function. it currently in singlestore module and imported into postgres module lol

if ts.tzinfo is None:
return ts
else:
return ts.astimezone(tz=timezone.utc).replace(tzinfo=None)