Skip to content

fix: Preserve every join key in remote online_read requests - #7007

Open
dbbvitor wants to merge 8 commits into
feast-dev:masterfrom
dbbvitor:fix/remote-online-read-composite-keys
Open

dbbvitor wants to merge 8 commits into
feast-dev:masterfrom
dbbvitor:fix/remote-online-read-composite-keys

Conversation

@dbbvitor

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

RemoteOnlineStore._construct_online_read_api_json_request built the request from row.join_keys[0]/row.entity_values[0] only, dropping every join key after the first for a composite entity key. The feature server then joined on a partial key, matched a row, and returned it with status PRESENT, no exception anywhere in the path, so callers got features for the wrong entity with no signal that anything went wrong. That's the core fix for #6488.

While finishing that fix, I ran into three more bugs in the same request/response path, each surfaced by tracing the previous one the rest of the way instead of stopping once the obvious part worked. All three are a few lines each, in the same two or three methods this PR already touches, with their own unit tests and (for the two reachable ones) integration coverage, so I fixed them here rather than opening three separate follow-up PRs for a reviewer to context-switch between. Each is called out below, so you can ask me to split any of them into their own PR if you'd rather review them separately.

#6603 (thanks @AmosBunde) already has the right core fix: zip join_keys with entity_values, key the output by name, raise on a length mismatch, but one reviewer comment blocked it (value.WhichOneof("val") returns None for an unset value, and
getattr(value, None) raises TypeError).

  1. The core fix (get_online_features on remote stores drops all join keys but the first #6488). The null-value fix uses this class's own converter. _proto_value_to_transport_value() is already the designated HTTP-transport converter here (used by the write path for feature values): it returns None for an unset value. the exact case blocking fix: Preserve all join keys in remote online store read requests #6603, and keeps complex types (JSON, map/struct, nested collections) JSON-safe, which a bare getattr(value, value.WhichOneof("val")) does not. For the scalar types fix: Preserve all join keys in remote online store read requests #6603 already handles (int, string, UnixTimestamp, read directly off the proto as a raw int either way), the two approaches behave the same; the real gain here is the None case plus safety for the rarer complex-typed join keys.

  2. Stumbled into while verifying (1.): _get_event_ts() hardcoded results[1] as "the first feature's result", which only held with exactly one entity column. Verified directly against the server's own response-building code (utils._populate_result_rows_from_columnar, utils._populate_response_from_feature_data): entity/join-key columns are written first, each stamped with a blank, epoch-zero Timestamp() on every row; the real per-row timestamps only appear on the feature columns written after them. With a composite key sending two join keys, results[1] becomes the second entity column, epoch-zero, not real. (1.) alone would have fixed the request and silently broken the response for exactly the composite-key case it's meant to support. This method now looks up the first requested feature by name when given one, instead of assuming a fixed index.

    This method is reachable from get_online_features() for every OTHER online store, but NOT for RemoteOnlineStore: RemoteOnlineStore.get_online_features() overrides the base class and builds its request directly from the caller's columnar entity_rows dict, so it was never exposed to this bug. The confirmed real caller of online_read() on a remote store is the feature-service precompute/materialization path (FeatureStore, around the loop that calls online_store.online_read(...) before write_precomputed_vector). That's the actual blast radius: a feature service backed by a remote online store, precomputing a composite-key feature view, not the typical get_online_features() call most users make.

  3. Stumbled into while fixing (2.): online_read() reused row 0's event_ts for every row in a batch result instead of each row's own timestamp, a different, pre-existing bug in the same method, with the same shape of fix (match the right thing per row instead of once). Fixed by splitting event-timestamp lookup into "find the matching result row" and "parse one row's timestamp", so the per-row loop can re-parse per row.

  4. Stumbled into while fixing (2.) and (3.): retrieve_online_documents_v2 had the same two problems in miniature. It could match a blank entity-column timestamp when no feature was explicitly requested (the server always appends a real-timestamped "distance" column; now matched against explicitly), and separately reused one event_ts for every row, same as (3.). Both fixed, with the same reasoning and the same kind of unit test.

    Tried extending the same fix to retrieve_online_documents (v1, not v2, a sibling method), but its real server-side response builder (FeatureStore.retrieve_online_documents) calls only utils._populate_result_rows_from_columnar, which stamps every column, including any "distance" column when present, with the identical blank epoch-zero timestamp. There is no real timestamp anywhere in that endpoint's response to recover, so matching by name would be a no-op in production. Left unchanged, the one place this PR deliberately did NOT follow the same pattern, because here it would have been a no-op change dressed up as a fix.

Which issue(s) this PR fixes:

Fixes #6488

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc

@dbbvitor
dbbvitor requested a review from a team as a code owner October 14, 2026 01:18
@codecov-commenter

codecov-commenter commented Oct 14, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.83%. Comparing base (4b37fff) to head (891a9e3).
⚠️ Report is 1 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7007   +/-   ##
=======================================
  Coverage   52.83%   52.83%           
=======================================
  Files         459      459           
  Lines       58331    58315   -16     
  Branches     8609     8606    -3     
=======================================
- Hits        30818    30811    -7     
+ Misses      25404    25398    -6     
+ Partials     2109     2106    -3     
Flag Coverage Δ *Carryforward flag
go-feature-server 30.96% <ø> (ø)
python-unit 54.36% <ø> (+<0.01%) ⬆️ Carriedforward from 4b37fff

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
sdk/python/feast/infra/online_stores/remote.py 65.52% <ø> (+1.13%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5585598...891a9e3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +235 to +237
def _create_composite_key_server_store_spin_feature_server(
temp_dir, auth_config: str, permissions_list, tls_mode
):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 New test signatures lack type hints

The new _create_composite_key_server_store_spin_feature_server helper and added tests omit parameter and return annotations. The repository requires type hints on every Python function signature.

Learn more

The new integration helper and both new integration tests have unannotated parameters and return values; the new unit test methods repeat this pattern. Repository instructions require type hints for all Python function signatures, including test code.

Example: _create_composite_key_server_store_spin_feature_server takes an untyped temp_dir and has no return annotation, so its new signature violates the rule even though existing test helpers use the same pattern.

Recommended fix: Add appropriate parameter and return annotations to the new integration helper, integration tests, and unit test methods. Use fixture and return types supported by the existing testing modules.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

RemoteOnlineStore._construct_online_read_api_json_request built the
request from row.join_keys[0]/row.entity_values[0] only, dropping
every join key past the first for a composite entity key. Build it
from every (join_key, value) pair instead, keyed by name via the
class's own HTTP-transport value converter, and raise on a
join_keys/entity_values length mismatch instead of silently
truncating.

_get_event_ts also assumed the first feature column always sat at a
fixed results[1], which only held with a single join key. Look up the
first requested feature by name instead, now that entity columns can
outnumber one.

Fixes feast-dev#6488

Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
…th mutant

The round-trip fixture's entity-column timestamps were a placeholder
guess. Verified directly against utils._populate_result_rows_from_columnar
(entity columns get a blank, epoch-zero Timestamp()) and
utils._populate_response_from_feature_data (feature columns get the
real per-row timestamp) and updated the fixture to match, including
distinct per-row feature timestamps. Also documents, rather than
silently glossing over, that online_read() reuses row 0's timestamp
for every row -- a separate, pre-existing, out-of-scope limitation.

Added a length-mismatch case above CPython's small-int cache (256):
the existing cases only compare tiny lengths, where a `!=`-to-`is not`
mutant on the equality check is unobservable because small ints are
interned.

Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
…rrect

Cut multi-line comments and issue-reference docstrings down to one
line each. Removed an assertion in the round-trip test that treated
online_read() reusing row 0's timestamp for every row as expected
behavior -- it would fail once that pre-existing, unrelated limitation
is ever fixed. Re-verified 100% diff-cover and 0 cosmic-ray survivors
after the removal.

Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
Add a type hint, bounds-check the matched result index, treat an
empty requested_features list like the legacy positional lookup, and
de-duplicate the timestamp parsing. Add an integration test covering
composite-key online_read.

Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
response_json.get("metadata", {}) only substitutes a default when the
key is absent, not when it's present with value null, so a server
response shaped like {"metadata": null} raised AttributeError instead
of degrading gracefully. Switch to the response.get("metadata") or {}
pattern already used by retrieve_online_documents_v2, and fold the
index/bounds bookkeeping into zip(feature_names, results).

Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
…ed_features

Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
online_read() and retrieve_online_documents_v2() both computed one
event_ts before their per-row loop and reused it for every row in the
batch. Split _get_event_ts into _find_event_ts_result (which results[]
row to read) and _parse_event_ts(result, row_idx) (parse one row from
it), so each loop can re-parse per row instead of once.

retrieve_online_documents_v2 also matched a blank entity-column
timestamp when no feature was explicitly requested; now matches
against requested_features + ["distance"], since the server always
appends a real-timestamped distance column.

retrieve_online_documents (v1) is left unchanged: its real response
builder stamps every column with the same blank epoch-zero timestamp,
so matching by name would be a no-op in production.

Adds an integration test that calls online_read() directly via the
provider -- the only reachable caller for a remote store, since
RemoteOnlineStore.get_online_features() builds its own request and
never calls online_read().

Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
@ntkathole
ntkathole force-pushed the fix/remote-online-read-composite-keys branch from 3ca99fe to 891a9e3 Compare November 17, 2026 05:43
@jyejare

jyejare commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@ntkathole Unit tests are failing, please take a look.

@jyejare jyejare left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The PR fixes the composite-key request bug by serializing every join key and improves event-timestamp selection so timestamps are taken from the requested feature result on a per-row basis. The unit and integration tests cover important regressions, including composite keys, Unix timestamp values, and document retrieval with no explicitly requested features. There are still edge cases in feature-name matching and entity-row validation that could produce missing timestamps or malformed requests.

Comment on lines +704 to 713
return None
return datetime.fromisoformat(event_timestamps[row_idx].replace("Z", "+00:00"))

def _find_event_ts_result(
self,
response_json: dict,
requested_features: Optional[List[str]] = None,
) -> Optional[dict]:
"""Return the results[] row holding the event timestamps to report, or None."""
results = response_json.get("results") or []

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The request builder qualifies features as table.name:feature, while requested_features may contain only the bare feature name. If the server returns qualified names in metadata.feature_names, this exact membership check will fail and online_read() will report None for the event timestamp even when the feature result has one. Normalize the names consistently or match the qualified request names as well; add a test using qualified metadata names.

Suggested:

Suggested change
return None
return datetime.fromisoformat(event_timestamps[row_idx].replace("Z", "+00:00"))
def _find_event_ts_result(
self,
response_json: dict,
requested_features: Optional[List[str]] = None,
) -> Optional[dict]:
"""Return the results[] row holding the event timestamps to report, or None."""
results = response_json.get("results") or []
feature_names = (response_json.get("metadata") or {}).get(
"feature_names"
) or []
requested_names = set(requested_features)
for feature_name, result in zip(feature_names, results):
bare_name = feature_name.rsplit(":", 1)[-1]
if feature_name in requested_names or bare_name in requested_names:
return result

Comment on lines 634 to 645
for row in entity_keys:
entity_key = row.join_keys[0]
entity_values.append(
getattr(row.entity_values[0], row.entity_values[0].WhichOneof("val")) # type: ignore[arg-type]
)
if len(row.join_keys) != len(row.entity_values):
raise ValueError(
f"Entity key has {len(row.join_keys)} join keys but "
f"{len(row.entity_values)} values; these must be the same length."
)
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
)

return {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The length check validates each row independently, but the resulting entity columns must also have consistent row counts. If one row has a different join-key set, a column is omitted for that row and the request contains arrays of different lengths, which can be rejected or misinterpreted by the server. Validate that all rows use the same unique join keys before appending values.

Suggested:

Suggested change
for row in entity_keys:
entity_key = row.join_keys[0]
entity_values.append(
getattr(row.entity_values[0], row.entity_values[0].WhichOneof("val")) # type: ignore[arg-type]
)
if len(row.join_keys) != len(row.entity_values):
raise ValueError(
f"Entity key has {len(row.join_keys)} join keys but "
f"{len(row.entity_values)} values; these must be the same length."
)
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
)
return {
entity_columns: Dict[str, List[Any]] = {}
expected_join_keys = set(entity_keys[0].join_keys) if entity_keys else set()
for row in entity_keys:
if len(row.join_keys) != len(row.entity_values):
raise ValueError("Join keys and entity values must have the same length.")
if len(set(row.join_keys)) != len(row.join_keys):
raise ValueError("Entity key contains duplicate join keys.")
if set(row.join_keys) != expected_join_keys:
raise ValueError("All entity rows must contain the same join keys.")
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(

Comment on lines +640 to 645
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
)

return {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A row with a duplicate name in join_keys passes the current length check, then appends multiple values to the same output column for that row. That makes the serialized column longer than the number of entity rows and can corrupt the request. Reject duplicate join-key names explicitly (in addition to validating the row schemas across the batch).

Suggested:

Suggested change
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
)
return {
if len(set(row.join_keys)) != len(row.join_keys):
raise ValueError("Entity key contains duplicate join keys.")
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
)

Comment on lines +707 to 713
def _find_event_ts_result(
self,
response_json: dict,
requested_features: Optional[List[str]] = None,
) -> Optional[dict]:
"""Return the results[] row holding the event timestamps to report, or None."""
results = response_json.get("results") or []

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When multiple requested features have different event timestamps, this loop selects the first matching feature in response metadata order, rather than in caller request order. If response ordering ever differs from request ordering, the single timestamp returned by online_read() can change unexpectedly. Consider selecting according to the documented timestamp policy—such as the first requested feature—or document that response order determines the result.

Suggested:

Suggested change
def _find_event_ts_result(
self,
response_json: dict,
requested_features: Optional[List[str]] = None,
) -> Optional[dict]:
"""Return the results[] row holding the event timestamps to report, or None."""
results = response_json.get("results") or []
results_by_name = dict(zip(feature_names, results))
for requested_feature in requested_features:
result = results_by_name.get(requested_feature)
if result is not None:
return result
return None

@jyejare jyejare left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Inconsistent join-key schemas can produce malformed entity columns, and the no-requested-features fallback can select an entity column's timestamp for composite keys; these cases should be addressed before merging.

Comment on lines 634 to +642
for row in entity_keys:
entity_key = row.join_keys[0]
entity_values.append(
getattr(row.entity_values[0], row.entity_values[0].WhichOneof("val")) # type: ignore[arg-type]
)
if len(row.join_keys) != len(row.entity_values):
raise ValueError(
f"Entity key has {len(row.join_keys)} join keys but "
f"{len(row.entity_values)} values; these must be the same length."
)
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This builds each entity column by appending only when a row contains that join key. If rows have different join-key sets, the resulting arrays have different lengths and values can be associated with the wrong request row by the server. Validate that every row has the same join-key set before constructing columns, and fail with a clear error rather than sending a ragged entity payload.

Suggested:

Suggested change
for row in entity_keys:
entity_key = row.join_keys[0]
entity_values.append(
getattr(row.entity_values[0], row.entity_values[0].WhichOneof("val")) # type: ignore[arg-type]
)
if len(row.join_keys) != len(row.entity_values):
raise ValueError(
f"Entity key has {len(row.join_keys)} join keys but "
f"{len(row.entity_values)} values; these must be the same length."
)
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
expected_join_keys = set(entity_keys[0].join_keys) if entity_keys else set()
entity_columns: Dict[str, List[Any]] = {key: [] for key in expected_join_keys}
for row in entity_keys:
if len(row.join_keys) != len(row.entity_values):
raise ValueError("Join keys and entity values must have the same length.")
if set(row.join_keys) != expected_join_keys or len(set(row.join_keys)) != len(row.join_keys):
raise ValueError("All entity keys must contain the same unique join keys.")
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns[join_key].append(self._proto_value_to_transport_value(value))

Comment on lines +716 to +728
feature_names = (response_json.get("metadata") or {}).get(
"feature_names"
) or []
for feature_name, result in zip(feature_names, results):
if feature_name in requested_features:
return result
return None
if len(results) > 1:
event_timestamps = results[1].get("event_timestamps") or []
if event_timestamps:
return datetime.fromisoformat(
event_timestamps[0].replace("Z", "+00:00")
)
return results[1]
return None

def _get_event_ts(
self,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When requested_features is empty, this fallback assumes results[1] is a feature column. With a composite entity key, the first two results can instead be the two entity columns, so this reports an entity column's timestamp (often the epoch sentinel) as the event timestamp. For an empty feature request, return None unless the response can reliably identify a non-entity result; update the legacy-fallback test to cover composite-key responses.

Suggested:

Suggested change
feature_names = (response_json.get("metadata") or {}).get(
"feature_names"
) or []
for feature_name, result in zip(feature_names, results):
if feature_name in requested_features:
return result
return None
if len(results) > 1:
event_timestamps = results[1].get("event_timestamps") or []
if event_timestamps:
return datetime.fromisoformat(
event_timestamps[0].replace("Z", "+00:00")
)
return results[1]
return None
def _get_event_ts(
self,
if not requested_features:
return None
feature_names = (response_json.get("metadata") or {}).get("feature_names") or []
for feature_name, result in zip(feature_names, results):
if feature_name in requested_features:
return result
return None

Comment on lines +639 to +642
)
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A row with a repeated join-key name currently appends multiple values to the same column, making that column longer than the number of entity rows and silently producing an invalid request. The equal-length check does not catch this malformed input. Validate that each row's join keys are unique before appending values.

Suggested:

Suggested change
)
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
if len(set(row.join_keys)) != len(row.join_keys):
raise ValueError("Entity key contains duplicate join keys.")
for join_key, value in zip(row.join_keys, row.entity_values):
entity_columns.setdefault(join_key, []).append(
self._proto_value_to_transport_value(value)
)

Comment on lines +1000 to +1040
"""The length check must use value equality, not identity."""
n = 300
matching = [
EntityKeyProto(
join_keys=[f"k{i}" for i in range(n)],
entity_values=[ValueProto(int64_val=i) for i in range(n)],
),
]

remote_store._construct_online_read_api_json_request(
matching, composite_key_feature_view, ["conv_rate"]
) # must not raise

# ── _get_event_ts ────────────────────────────────────────────────────

def test_get_event_ts_none_when_requested_feature_has_no_timestamps(
self, remote_store
):
"""A matched requested feature with no event_timestamps must return
None rather than raise or fall back to a different column."""
response_json = {
"metadata": {"feature_names": ["driver_id", "conv_rate"]},
"results": [
{"values": [1001], "event_timestamps": ["1999-01-01T00:00:00Z"]},
{"values": [0.5], "event_timestamps": []},
],
}

assert remote_store._get_event_ts(response_json, ["conv_rate"]) is None

def test_get_event_ts_none_when_requested_feature_absent(self, remote_store):
"""No requested feature appearing in feature_names must return None, not a stale timestamp from results[1]."""
response_json = {
"metadata": {"feature_names": ["driver_id", "customer_id"]},
"results": [
{"values": [1001], "event_timestamps": ["1999-01-01T00:00:00Z"]},
{"values": [5001], "event_timestamps": ["1999-01-01T00:00:00Z"]},
],
}

assert remote_store._get_event_ts(response_json, ["conv_rate"]) is None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The new timestamp-selection tests exercise one requested feature at a time. Since _find_event_ts_result returns the first matching feature in response metadata order, add a case with multiple requested features and differing or missing timestamp arrays to make the intended selection rule explicit and prevent response ordering from causing regressions.

Suggested:

Suggested change
"""The length check must use value equality, not identity."""
n = 300
matching = [
EntityKeyProto(
join_keys=[f"k{i}" for i in range(n)],
entity_values=[ValueProto(int64_val=i) for i in range(n)],
),
]
remote_store._construct_online_read_api_json_request(
matching, composite_key_feature_view, ["conv_rate"]
) # must not raise
# ── _get_event_ts ────────────────────────────────────────────────────
def test_get_event_ts_none_when_requested_feature_has_no_timestamps(
self, remote_store
):
"""A matched requested feature with no event_timestamps must return
None rather than raise or fall back to a different column."""
response_json = {
"metadata": {"feature_names": ["driver_id", "conv_rate"]},
"results": [
{"values": [1001], "event_timestamps": ["1999-01-01T00:00:00Z"]},
{"values": [0.5], "event_timestamps": []},
],
}
assert remote_store._get_event_ts(response_json, ["conv_rate"]) is None
def test_get_event_ts_none_when_requested_feature_absent(self, remote_store):
"""No requested feature appearing in feature_names must return None, not a stale timestamp from results[1]."""
response_json = {
"metadata": {"feature_names": ["driver_id", "customer_id"]},
"results": [
{"values": [1001], "event_timestamps": ["1999-01-01T00:00:00Z"]},
{"values": [5001], "event_timestamps": ["1999-01-01T00:00:00Z"]},
],
}
assert remote_store._get_event_ts(response_json, ["conv_rate"]) is None
def test_get_event_ts_uses_first_matching_requested_feature_by_response_order(self, remote_store):
response_json = {
"metadata": {"feature_names": ["driver_id", "conv_rate", "other_rate"]},
"results": [
{"event_timestamps": ["1970-01-01T00:00:00Z"]},
{"event_timestamps": ["2024-01-01T00:00:00Z"]},
{"event_timestamps": ["2024-01-02T00:00:00Z"]},
],
}
assert remote_store._get_event_ts(response_json, ["other_rate", "conv_rate"]) == datetime(
2024, 1, 1, tzinfo=timezone.utc
)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_online_features on remote stores drops all join keys but the first

4 participants