Repository navigation
feat: Retrieve historical features from Snowflake without an entity dataframe - #7161
NopeCharon wants to merge 2 commits into
Conversation
…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>
| def test_non_entity_mode_uploads_left_table_query_as_temporary_table( | ||
| repo_config, snowflake_conn, upload_entity_df | ||
| ): |
There was a problem hiding this comment.
🟡 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
What this PR does / why we need it:
Snowflake didn't support entity-less historical retrieval.
SnowflakeOfflineStore.get_historical_featuresdidn't acceptstart_dateorend_date, so this failed:This PR adds a non-entity mode that works the same way as in the BigQuery, Spark and Trino offline stores. When
entity_dfisNone, the left side of the point-in-time join is built from the data:UNIONof the distinct join keys found in each feature view source betweenstart_dateandend_date.end_date, so each entity gets its latest feature values within the TTL.Details:
_upload_entity_dfpath, the one SQL-string entity dataframes already use. TheASOF JOINtemplate doesn't change. No schema orMIN/MAXtimestamp queries are sent, because the columns and the time range are already known.custmapped tocustomer_idbecomes"cust" AS "customer_id". Query-basedSnowflakeSources work too.NULLin 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 atend_date.start_dateandend_dateget their defaults fromcompute_non_entity_date_range, like in the other stores. The time-window filter is built withget_timestamp_filter_sqlin UTC, the same waypull_all_from_table_or_querybuilds it. The Snowflake connection already sets the session time zone to UTC.full_feature_namesand on-demand feature views work as they do in entity-df mode. Snowflake still doesn't supportfilter_by_created_timestamp, so the provider rejects it as before.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
git commit -s)Testing Strategy
Unit tests (
tests/unit/infra/offline_stores/test_snowflake_non_entity_mode.py) cover:NULLfilling across feature views, skipping feature views without entities, the single-row case, and UTC conversion;get_historical_featuresflow: 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 thestart_datedefault are correct;The new tests fail on
master. All tests undertests/unit/infra/offline_stores/still pass.ruff check,ruff format --checkandmypyonsnowflake.pyare 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 parseASOF JOIN ... MATCH_CONDITION, so the test script rewrote that one clause into the equivalent DuckDBASOF JOIN ... ON. Everything else ran as Feast generated it:end_date. Thecreated_timestampdedup picked the right row. Entities with events only beforestart_dateor afterend_datewere left out.end_dateworked (start_datedefaulted to the TTL).full_feature_names=True.SnowflakeSourceworked.On
masterthe same script fails with theTypeErrorabove.Misc