Skip to content

Remote online store materialization fails for UnixTimestamp feature values #6492

@dbbvitor

Description

@dbbvitor

Expected Behavior

Materializing a feature view that contains one or more UnixTimestamp feature columns into a remote online store should succeed.

The remote online-store client should serialize timestamp-valued feature payloads into a JSON-safe representation before calling the feature server.

Current Behavior

When online_store.type: remote is used and a feature value itself is typed as UnixTimestamp, materialization fails in the remote client before the request is sent.

The failure path is:

  • RemoteOnlineStore.online_write_batch() builds req_body
  • feature values are converted via _proto_value_to_transport_value()
  • unix_timestamp_val falls through to feast_value_type_to_python_type(...)
  • Feast returns a timezone-aware Python datetime
  • requests.post(..., json=req_body) calls json.dumps(...)
  • JSON encoding fails with:
TypeError: Object of type datetime is not JSON serializable

A representative feature view looks like:

schema=[
    Field(name="first_checkin_timestamp", dtype=UnixTimestamp),
    Field(name="last_checkin_timestamp", dtype=UnixTimestamp),
    Field(name="total_checkins", dtype=Int64),
    Field(name="item_type", dtype=String),
]

The source event_timestamp / created_timestamp_column do not have this problem because online_write_batch() already serializes those fields explicitly with .isoformat(). The issue only affects timestamp-valued feature columns.

This was observed with a Trino-backed feature view, but the bug appears to be backend-independent because the exception is raised in the remote online-store HTTP transport before the request reaches the server.

Steps to reproduce

  1. Configure Feast with a remote online store (online_store.type: remote) pointing at a Feast feature server.
  2. Define a feature view with at least one feature column of dtype UnixTimestamp.
  3. Ensure the feature view can be materialized normally from the offline store.
  4. Run materialization, for example:
from datetime import datetime, timezone

start = datetime(2023, 1, 1, 0, 0, tzinfo=timezone.utc)
end = datetime(2027, 1, 1, 0, 0, tzinfo=timezone.utc)

fs.materialize(
    start_date=start,
    end_date=end,
    disable_event_timestamp=True,
    feature_views=["historical_item_usage_view_v2"],
)
  1. Observe the remote online-store write failure:
File ".../feast/infra/online_stores/remote.py", line ..., in online_write_batch
  response = post_remote_online_write(config=config, req_body=req_body)
...
File ".../json/encoder.py", line 180, in default
  raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable

Specifications

  • Version: v0.63.0
  • Platform: Linux / Python 3.12
  • Subsystem: remote online store / materialization / HTTP transport

Possible Solution

Handle UnixTimestamp feature values explicitly in the remote transport path instead of letting them fall through to feast_value_type_to_python_type(...).

For example, in RemoteOnlineStore._proto_value_to_transport_value() / online_write_batch():

  • serialize unix_timestamp_val into a JSON-safe transport format
    • preferably epoch integer(s), since UNIX_TIMESTAMP already round-trips cleanly from numeric values
    • alternatively ISO-8601 strings, if the server-side write path also parses them back using the feature schema
  • keep the existing explicit handling for event_timestamp / created

At the moment the code special-cases JSON/UUID/Map/Struct transport, but not timestamp-valued feature payloads, which makes remote materialization fail for UnixTimestamp features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions