Skip to content

feat: Batch Bigtable online reads across feature views - #7198

Merged
ntkathole merged 3 commits into
feast-dev:masterfrom
Zhuoxi2000:fix-bigtable-batched-read-3259
Nov 22, 2026
Merged

ntkathole merged 3 commits into
feast-dev:masterfrom
Zhuoxi2000:fix-bigtable-batched-read-3259

Conversation

@Zhuoxi2000

@Zhuoxi2000 Zhuoxi2000 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Part of #3259: get_online_features makes one store call per feature view. As with Redis, PostgreSQL (#6832) and DynamoDB (#7134), this adds a per-store _read_features_per_fv override, here for Bigtable.

Bigtable already co-locates what the issue asks to read together. Every feature view keyed on the same entities shares one Bigtable table (_get_table_name is built from the sorted entities and the project), and each view's rows are keyed {entity_id}#{feature_view_name}. The generic path still sent one ReadRows call per feature view. Now the rows of all those views come back from one call.

Changes in sdk/python/feast/infra/online_stores/bigtable.py:

  • BigtableOnlineStore._read_features_per_fv groups the requested views by Bigtable table and issues one ReadRows call per table. The RowSet holds the row keys of every view in that table. Each view's rows are then picked out by row key, and _populate_response_from_feature_data is called in grouped_refs order, so the response layout is unchanged.
  • The filter of that call is a RowFilterUnion with one branch per feature view: a RowKeyRegexFilter matching that view's row keys (^[0-9a-f]+#<escaped view name>$) chained with a ColumnQualifierRegexFilter for the features requested from that view plus event_ts. A view requested without a feature list gets the row-key condition alone. A row key matches exactly one branch, so each view's rows pass only the columns requested from that view, as on the per-view path. This holds for whatever the rows contain, including a qualifier left behind by a feature that was later removed from the view. (The first commit used one column filter for the whole table and the second added a check against the views' schemas; both were replaced after review.)
  • A request naming a feature view whose name is not plain ASCII keeps the generic path, because the row key pattern is only built for ASCII names.
  • One feature view requested under two aliases reads the same rows. Its row keys are deduplicated and each row is decoded once, because _process_bt_row pops event_ts from the row's cells.
  • A single-view request keeps the generic path. So does any request larger than the new max_batched_result_rows (entity rows × feature views, default 2048). max_batched_result_rows: 0 turns batching off. The knob and its default mirror PostgreSQL and DynamoDB.
  • Bigtable rejects a row filter larger than 20 KB (quotas, "Row filters limits"), and the batched read puts the row key pattern and the features of every view of a table into one filter. If that filter would be larger than MAX_BATCHED_FILTER_BYTES (16,000 bytes, a margin under the limit), the request keeps the generic path, so a wide request that works on master still sends the same per-view filters. The size is an upper bound computed from the regexes plus 32 bytes per view for the proto framing. With 24-character feature names this takes about 640 requested features in one table.
  • online_read and the batched path share a new _read_rows(config, bt_table_name, row_keys, filter_) helper and the _column_filter / _column_filter_regex helpers. For online_read the filter expression and the found-rows-by-key mapping are the same as before.
  • Sync only. Bigtable has no online_read_async.

Docs: a "Bigtable exception" paragraph in docs/how-to-guides/online-server-performance-tuning.md next to the Redis/PostgreSQL/DynamoDB ones, the Bigtable row in the store table there, and a "Batched Multi-Feature-View Reads" section in docs/reference/online-stores/bigtable.md.

Not covered here:

Which issue(s) this PR fixes:

Refs #3259. That issue is labelled keep-open and covers several stores, so this PR does not close it.

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

New sdk/python/tests/unit/infra/online_store/test_bigtable_batched_read.py. It follows test_bigtable_online_store.py: it uses pytest.importorskip("google.cloud.bigtable") and patches BigtableOnlineStore._get_client. The client is replaced by an in-memory fake that records every read_rows call and the cells it returns, and evaluates the union, chain, row-key regex and column-qualifier regex filters. The result tests also compare the response with OnlineStore._read_features_per_fv on the same data. The tests cover:

  • 3 views on the same entity -> 1 read_rows call with 6 row keys, instead of 3 calls; same response as the generic path.
  • Views on two entity sets -> 2 calls; same response, including a missing customer row (NOT_FOUND) and a repeated driver row.
  • The same feature name in two views returns each view's own value.
  • One view under two aliases with different feature subsets -> 1 call with 2 row keys (not 4).
  • A single-view request goes through the generic path.
  • max_batched_result_rows 0 / 3 / 4 for a 2-entity × 2-view request -> 2 / 2 / 1 calls; the default is 2048 and negative values are rejected.
  • Two views whose filter is exactly 16,000 bytes -> 1 call; one byte more -> 2 calls; same response as the generic path in both cases. The size estimate is at least the serialized size of the filter.
  • Two views that both store score and extra: score from one and extra from the other; one of them without a feature list; the same features from both. Each is 1 call, and the fake returns the same feature cells as on the generic path.
  • A view whose rows still hold a payload qualifier that its schema no longer lists, with payload requested from another view -> 1 call, the retired cell is not returned, same cells as the generic path.
  • View names where one ends with another, and names containing . and # -> 1 call, same cells as the generic path.
  • A non-ASCII view name -> 2 calls.
pytest sdk/python/tests/unit/infra/online_store/test_bigtable_batched_read.py \
       sdk/python/tests/unit/infra/online_store/test_bigtable_online_store.py \
       sdk/python/tests/unit/infra/online_store/test_online_store_base.py -rs
31 passed (0 skipped)

With bigtable.py from master (plus the two constants so the test module imports), 17 of the 19 new tests fail; the single-view test and the non-ASCII test pass there, since they check behaviour that already exists. With bigtable.py from the second commit (229c1f6), the retired-qualifier test fails because the payload cell of the first view is returned.

Those are mock-level tests. I also ran a scratch script against Google's Bigtable emulator (cloud.google.com/go/bigtable/cmd/emulator): it creates the tables with update, writes with online_write_batch, and reads the same request through the batched path and through OnlineStore._read_features_per_fv. The script also records the cells each ReadRows call returns. Responses and cells were identical in all nine request shapes:

request ReadRows calls, batched generic
2 views with distinct feature names 1 2
2 views storing the same names, a different one requested from each 1 2
2 views, one without a feature list 1 2
2 views, the same shared name from both 1 2
3 views on one entity 1 3
one view under two aliases plus another view 1 3
a view with a retired payload qualifier, payload requested from another view 1 2
5 views with similar names (suffix of another, ., #) 1 5
only entities that are not stored 1 2

The emulator does not enforce the 20 KB limit (it accepted a 22,852-byte filter when I forced batching on the first commit), so the fallback itself is covered by the unit test and the quota documentation, not by a rejected request. I did not run the LocalCloud test (tests/localcloud/test_localcloud_gcp.py::test_bigtable_online_store_round_trip) or anything against a real Bigtable instance.

ruff check and ruff format --check (0.16.9) pass on the touched files. mypy on feast/infra/online_stores/bigtable.py reports no issues.

Misc

Size: +224/−23 in bigtable.py, +7/−1 in docs, and +467 for the new test file (698 added lines in total; the PostgreSQL and DynamoDB PRs were +827 and +710).


Devin Review

@Zhuoxi2000
Zhuoxi2000 requested a review from a team as a code owner November 21, 2026 05:17

@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.

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

Devin Review

Comment on lines +155 to +160
features = features_by_table[bt_table_name]
features_by_table[bt_table_name] = (
list(dict.fromkeys(features + requested_features))
if features and requested_features
else None
)

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.

🔴 Unrequested columns exhaust serving memory

When co-located views share column names but request different subsets, features_by_table fetches unrequested values from each view. _read_rows buffers those values before response filtering, so a previously safe request can exhaust server memory.

Learn more

get_online_features previously used the per-view read loop, which sent each view's own column filter. The batched path uses one union of those filters for every row in a table. _read_rows collects the entire result in memory, then _process_bt_row decodes all columns before response population discards the extras. The batching guards cap filter size and row count, not this payload.

Example: Request 200 entities across ten views on the same entities. Each view stores the same ten column names as 64 KiB byte features, and the service selects a different one from each view. The request stays below 2,048 rows and uses a short filter. The old path reads 125 MiB of feature values in total. The batch buffers about 1.22 GiB of raw feature values alone, enough to exceed a 1 GiB server limit before decoding.

Recommended fix: Preserve each row's column projection in the backend. For example, batch only rows that share the same requested qualifier set, or use a row-key-aware filter with the existing size fallback. Cover co-located views that store the same columns but request disjoint subsets, and assert that the backend does not return the extra cells.

Devin Review


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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 229c1f6. The shared filter did match a column that one view stores under the same name as a feature requested from another view. A request where that would happen now reads one feature view at a time, so a batched read returns the same cells as the per-view reads. The check compares each view's schema with the shared filter, so views with distinct feature names, and views asked for the same shared names, are still batched. It is covered by test_unrequested_columns_are_not_read.

I did not use a row-key-aware filter. It would add a row-key condition per view to a filter that already has to stay under the 20 KB limit, and I can only check its behaviour on the emulator, not on a real instance.

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.

the current schema check still misses cells left by schema changes. removing a feature from a view does not delete its Bigtable qualifier: update retains the table and _write_rows_to_bt only sets the supplied cells. if view A formerly stored a large payload feature, now requests only score, and view B requests payload, the union filter fetches A's retired payload too. table.features no longer contains it, so the fallback does not run and the extra cells are buffered and decoded. we need to preserve each view's requested qualifier set at the backend, including retired columns, and add a regression with a stored qualifier absent from the current schema.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6717b40. You're right, the schema check could not see a qualifier left behind by a removed feature.

The batched read now uses the row-key-aware filter. It is a RowFilterUnion with one branch per feature view: a RowKeyRegexFilter for that view's row keys (^[0-9a-f]+#<escaped view name>$) chained with the view's own ColumnQualifierRegexFilter. A view requested without a feature list gets the row-key condition alone. Each row key matches exactly one branch, so every view keeps its own qualifier set at the backend whatever its rows hold, and the schema check is removed. Requests that fell back to per-view reads because of shared names are batched again.

The 16,000-byte fallback now measures the whole filter (every regex plus a per-view allowance for the proto framing; a test checks that this is an upper bound on the serialized size). A request naming a feature view whose name is not plain ASCII reads one view at a time, since I only build the row key pattern for ASCII names.

Regression: test_column_removed_from_the_schema_is_not_read stores a payload qualifier on fv_a that its schema does not list, requests score from fv_a and payload from fv_b, and asserts that fv_a's payload cell is not returned and that the cells match the per-view path. It fails on 229c1f6.

I said earlier that I could only check this kind of filter on the emulator, and that is still the case. I ran nine request shapes against Google's Bigtable emulator, including the retired qualifier, view names where one ends with another, and names containing . and #; the cells and responses match the per-view path in each. The emulator does not enforce the 20 KB filter limit, and nothing was run against a real instance.

@codecov-commenter

codecov-commenter commented Nov 21, 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 53.81%. Comparing base (025a02c) to head (a9d2318).
⚠️ Report is 3 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    #7198      +/-   ##
==========================================
+ Coverage   53.70%   53.81%   +0.10%     
==========================================
  Files         462      462              
  Lines       58556    58628      +72     
  Branches     8637     8649      +12     
==========================================
+ Hits        31447    31549     +102     
+ Misses      24972    24939      -33     
- Partials     2137     2140       +3     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.40% <100.00%> (+0.11%) ⬆️
Files with missing lines Coverage Δ
sdk/python/feast/infra/online_stores/bigtable.py 75.11% <100.00%> (+33.73%) ⬆️

... and 1 file with indirect coverage changes


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 025a02c...a9d2318. 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.

@franciscojavierarceo franciscojavierarceo left a comment

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.

we need to finish the projection fix in the existing thread. the current-schema guard cannot account for retired Bigtable qualifiers, so requests can still fetch and retain large values that the previous per-view path excluded. the thread now has a concrete schema-evolution case to cover.

Feature views keyed on the same entities share one Bigtable table, and
each view's rows are keyed {entity_id}#{feature_view_name}. The generic
_read_features_per_fv still issued one ReadRows call per feature view.

BigtableOnlineStore now overrides _read_features_per_fv to group the
requested views by Bigtable table and fetch each table's rows with a
single ReadRows call, using the union of the requested feature columns.
Row keys shared by one view requested under several aliases are read
and decoded once. Single-view requests, and requests larger than the
new max_batched_result_rows (entity rows x feature views, default 2048,
0 turns batching off), keep the per-view path, as for PostgreSQL and
DynamoDB. So does a request whose union column filter would pass
16,000 bytes, because Bigtable rejects a row filter over 20 KB.

online_read and the batched path share a new _read_rows helper.

Refs feast-dev#3259

Signed-off-by: Edson <zhuoxi2000@gmail.com>
The column filter of a batched read is shared by every feature view of a
Bigtable table, so it also matched a column that one view stores under the
same name as a feature requested from another view. Those cells were read
and decoded, then dropped when the response was built.

A request where the shared filter would return such a column now reads one
feature view at a time, like a request over the size limits.

Signed-off-by: Edson <zhuoxi2000@gmail.com>
A batched read used one column filter for every feature view of a Bigtable
table, and fell back to per-view reads when a view's current schema showed
that the filter would return an unrequested column. That check could not see
a column left behind by a feature that was later removed from a view: update
keeps the table and online_write_batch only sets the cells it is given, so
the old cells were still read and decoded.

The filter of a batched read now has one branch per feature view, which
matches the view's rows by row key and passes only the features requested
from that view. A batched read returns the same cells as the per-view reads
whatever the rows hold, so the schema check is gone. The size limit is
applied to the whole filter, and a request naming a feature view whose name
is not plain ASCII reads one view at a time.

Signed-off-by: Edson <zhuoxi2000@gmail.com>
@ntkathole
ntkathole force-pushed the fix-bigtable-batched-read-3259 branch from 6717b40 to a9d2318 Compare November 22, 2026 12:56
@ntkathole
ntkathole merged commit 450e5ec into feast-dev:master Nov 22, 2026
19 of 22 checks passed
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.

4 participants