Skip to content

feat: Retrieve historical features from Snowflake without an entity dataframe - #7161

Open
NopeCharon wants to merge 2 commits into
feast-dev:masterfrom
NopeCharon:feat/snowflake-non-entity-retrieval
Open

NopeCharon wants to merge 2 commits into
feast-dev:masterfrom
NopeCharon:feat/snowflake-non-entity-retrieval

Conversation

@NopeCharon

@NopeCharon NopeCharon commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Snowflake didn't support entity-less historical retrieval. SnowflakeOfflineStore.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: SnowflakeOfflineStore.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, Spark and Trino 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 query is written to a temporary table through the existing _upload_entity_df path, the one SQL-string entity dataframes already use. The ASOF JOIN template doesn't change. No schema or MIN/MAX timestamp queries are sent, because the columns and the time range are already known.
  • The query uses the query context's quoted 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 SnowflakeSources work too.
  • 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. The time-window filter is built with get_timestamp_filter_sql in UTC, the same way pull_all_from_table_or_query builds it. The Snowflake connection already sets the session time zone to UTC.
  • full_feature_names and on-demand feature views work as they do in entity-df mode. Snowflake still doesn't support filter_by_created_timestamp, so the provider rejects it as before.
  • Entity-df retrieval (pandas or SQL) is unchanged.

Docs: the Snowflake offline store reference now describes the mode. Snowflake 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 #5828

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/test_snowflake_non_entity_mode.py) cover:

  • the generated entity query: 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: the entity query is uploaded as a temporary table when the query runs and the point-in-time join reads from that table; no entity schema or timestamp range queries are sent; the final column list, the metadata, and the start_date default are correct;
  • a regression test that entity-df mode still uploads the entity dataframe as before.

The new tests fail on master. All tests under tests/unit/infra/offline_stores/ still pass. ruff check, ruff format --check and mypy on snowflake.py are clean.

Manual end-to-end test: I ran the full FeatureStore.get_historical_features(...).to_df() flow against fakesnow, a local Snowflake emulator. fakesnow can't parse ASOF JOIN ... MATCH_CONDITION, so the test script rewrote that one clause into the equivalent DuckDB ASOF JOIN ... ON. Everything else ran as Feast generated it:

  • Retrieving one feature view over a date range gave the same rows as SQL entity-df retrieval for the same entities at end_date. The created_timestamp dedup picked the right row. Entities with events only before start_date or after end_date were left out.
  • Retrieval with only end_date worked (start_date defaulted to the TTL).
  • 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.
  • A query-based SnowflakeSource worked.
  • A window with no events returned an empty dataframe with the expected columns.

On master the same script fails with the TypeError above.

Misc


Devin Review

…ataframe

SnowflakeOfflineStore.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
Snowflake.

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, Spark and Trino offline
stores.

The entity query is written to a temporary table through the same
_upload_entity_df path that SQL entity dataframes already use, so the
existing ASOF JOIN template is reused unchanged and no extra schema or
timestamp-range queries are issued. The query selects through the
query context's quoted entity selections and timestamp field, so field
mappings and join key projections are honoured, and query-based
SnowflakeSources work. 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, and the window
filter uses get_timestamp_filter_sql in UTC like
pull_all_from_table_or_query.

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

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@NopeCharon
NopeCharon requested a review from a team as a code owner November 14, 2026 16:11

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

Devin Review

Comment on lines +256 to +258
def test_non_entity_mode_uploads_left_table_query_as_temporary_table(
repo_config, snowflake_conn, upload_entity_df
):

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.

🟡 Missing required Snowflake integration coverage

The new get_historical_features mode lacks the universal integration test required by the component rules. Tests mock _upload_entity_df and inspect SQL strings, leaving temporary-table creation and ASOF execution untested.

Learn more

The component checklist requires a universal integration test when retrieval behavior changes. The new unit tests replace database operations with mocks, so they cannot verify that Snowflake accepts the generated SQL or returns the expected feature values. Existing non-entity integration tests are restricted to Ray, and the historical retrieval integration test restricts its non-entity case to the file store.

Example: A Snowflake request for one driver feature over a date range passes these string assertions even if temporary-table creation or the subsequent ASOF query fails during execution.

Recommended fix: Add a universal integration case enabled for Snowflake that calls FeatureStore.get_historical_features(..., start_date=..., end_date=...).to_df() and checks entity membership, the end-date timestamp, latest-value selection, and TTL behavior. Run the relevant integration suite as required by the component checklist.

Devin Review


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

@codecov-commenter

codecov-commenter commented Nov 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.64%. Comparing base (108c967) to head (37968ef).
❗ 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    #7161      +/-   ##
==========================================
+ Coverage   52.55%   52.64%   +0.08%     
==========================================
  Files         459      459              
  Lines       58202    58235      +33     
  Branches     8582     8586       +4     
==========================================
+ Hits        30590    30657      +67     
+ Misses      25523    25488      -35     
- Partials     2089     2090       +1     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 54.16% <100.00%> (+0.09%) ⬆️
Files with missing lines Coverage Δ
sdk/python/feast/infra/offline_stores/snowflake.py 47.17% <100.00%> (+9.64%) ⬆️

... and 2 files 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 108c967...37968ef. 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.

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>

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

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snowflake - historical retrieval without entity dataframe

3 participants