Skip to content

feat: Retrieve historical features from Trino without an entity dataframe - #7150

Merged
ntkathole merged 1 commit into
feast-dev:masterfrom
NopeCharon:feat/trino-non-entity-retrieval
Nov 14, 2026
Merged

ntkathole merged 1 commit into
feast-dev:masterfrom
NopeCharon:feat/trino-non-entity-retrieval

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Trino didn't support entity-less historical retrieval. TrinoOfflineStore.get_historical_features didn't accept start_date or end_date, so this failed:

store.get_historical_features(
    features=["driver_stats:conv_rate"],
    start_date=datetime(2025, 7, 1),
    end_date=datetime(2025, 7, 10),
)
# TypeError: TrinoOfflineStore.get_historical_features() got an unexpected keyword argument 'start_date'

This PR adds a non-entity mode that works the same way as in the BigQuery and Spark offline stores. When entity_df is None, the left side of the point-in-time join is built from the data:

  • It takes a UNION of the distinct join keys found in each feature view source between start_date and end_date.
  • Every row gets the timestamp end_date, so each entity gets its latest feature values within the TTL.

Details:

  • The entity subquery goes straight into the existing MULTIPLE_FEATURE_VIEW_POINT_IN_TIME_JOIN template. No temporary table is created, so the mode also works on read-only catalogs and there is nothing to clean up.
  • The subquery uses the query context's entity selections and timestamp field, so field mappings and join key projections work. For example, a source column cust mapped to customer_id becomes cust AS customer_id. Query-based TrinoSources are wrapped in parentheses.
  • If a feature view doesn't have one of the join keys, that key is NULL in its rows. Feature views without entities don't add rows, because they join on the timestamp only. If no feature view has entities, the left side is a single row at end_date.
  • start_date and end_date get their defaults from compute_non_entity_date_range, like in the other stores. filter_by_created_timestamp, full_feature_names and on-demand feature views work as they do in entity-df mode.
  • Timestamps are passed as UTC ISO-8601 literals (from_iso8601_timestamp('...+00:00')), so they don't depend on the session time zone.
  • Entity-df retrieval (pandas or SQL) is unchanged.

Docs: the Trino offline store reference now describes the mode. Trino is added to the list of supported stores on the feature retrieval concepts page and in the FAQ.

Which issue(s) this PR fixes:

Fixes #5840

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

Unit tests (tests/unit/infra/offline_stores/contrib/trino_offline_store/test_trino_non_entity_mode.py) cover:

  • the generated entity subquery: time range filter, field-mapped columns, query-based sources, NULL filling across feature views, skipping feature views without entities, the single-row case, and UTC conversion;
  • the get_historical_features flow: no upload and no temporary table, final column list, metadata, start_date default, and filter_by_created_timestamp;
  • a regression test that entity-df mode still uploads the entity dataframe.

The new tests fail on master. The existing Trino unit tests still pass. ruff check, ruff format --check and mypy on trino.py are clean.

Manual end-to-end test against trinodb/trino:376 (the image used by the Trino test data source) with the memory connector:

  • Retrieving one feature view over a date range gave the same rows as entity-df retrieval for the same entities at end_date. An entity with no events in the range was left out.
  • Retrieval with only end_date worked.
  • Two feature views with disjoint entities, one with a field-mapped source, worked with full_feature_names=True.
  • A feature view without entities worked on its own and together with an entity feature view.
  • filter_by_created_timestamp=True worked.
  • A query-based TrinoSource worked.
  • Entity-df retrieval with a SQL string still worked.

On master the same script fails with the TypeError above.

Misc

@NopeCharon
NopeCharon requested a review from a team as a code owner November 13, 2026 04:57
@codecov-commenter

codecov-commenter commented Nov 13, 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.45%. Comparing base (cc17aad) to head (c219fb6).
⚠️ Report is 2 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    #7150   +/-   ##
=======================================
  Coverage   52.45%   52.45%           
=======================================
  Files         459      459           
  Lines       58172    58172           
  Branches     8577     8577           
=======================================
  Hits        30515    30515           
  Misses      25573    25573           
  Partials     2084     2084           
Flag Coverage Δ *Carryforward flag
go-feature-server 30.96% <ø> (ø)
python-unit 53.96% <ø> (ø) Carriedforward from cc17aad

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

Files with missing lines Coverage Δ
...ffline_stores/contrib/trino_offline_store/trino.py 38.34% <ø> (ø)

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 cc17aad...c219fb6. 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.

…rame

TrinoOfflineStore.get_historical_features did not accept start_date or
end_date, so calling FeatureStore.get_historical_features without an
entity_df failed with "unexpected keyword argument 'start_date'" on
Trino.

When entity_df is None, build the left side of the point-in-time join
from the data itself: a UNION of the distinct join keys that each
feature view source has between start_date and end_date, with every
row stamped at end_date. Each entity then gets its latest feature
values within the TTL, matching the BigQuery and Spark offline stores.

The entity subquery is inlined into the existing point-in-time
template, so no temporary table is created and read-only catalogs
work. It selects through the query context's entity selections and
timestamp field, so field mappings and join key projections are
honoured. Join keys a feature view does not have are filled with NULL,
feature views without entities join on the timestamp only, and when no
feature view has entities the left side is a single row at end_date.
start_date and end_date default through compute_non_entity_date_range
like the other stores.

Document entity-less retrieval for Trino in the offline store reference,
the feature retrieval concepts page and the FAQ.

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@ntkathole
ntkathole force-pushed the feat/trino-non-entity-retrieval branch from aa9a31a to c219fb6 Compare November 14, 2026 03:36
@ntkathole
ntkathole merged commit 6b8ee61 into feast-dev:master Nov 14, 2026
17 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.

Trino - historical retrieval without entity dataframe

4 participants