Repository navigation
feat: Retrieve historical features from Couchbase Columnar without an entity dataframe - #7188
NopeCharon wants to merge 2 commits into
Conversation
… entity dataframe CouchbaseColumnarOfflineStore.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 Couchbase Columnar. When entity_df is None, build the left side of the point-in-time join from the data itself: the distinct join keys that each feature view source has between start_date and end_date, combined with UNION ALL, 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 subquery is inlined into the existing SQL++ point-in-time template, so no entity collection is created or dropped. It selects through the query context's entity selections and timestamp field, so field mappings and join key projections are honoured, and timestamps use the same normalized string format as pull_latest_from_table_or_query. 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 Couchbase Columnar in the offline store reference, the feature retrieval concepts page and the FAQ. Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
There was a problem hiding this comment.
Devin Review found 2 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| start_timestamp = normalize_timestamp(start_date) | ||
| end_timestamp = normalize_timestamp(end_date) |
There was a problem hiding this comment.
🟡 Truncated cutoff drops boundary events
With fractional-second end_date, normalize_timestamp truncates the synthetic cutoff, excluding valid events in that second. The string upper bound also excludes same-second timestamps formatted by df_to_columnar, even at an exact-second cutoff. Retrieval silently omits entities or returns older features.
Learn more
The default normalize_timestamp format omits fractional seconds and emits a compact UTC offset. The synthetic entity timestamp now uses that format for both source filtering and the point-in-time cutoff. In contrast, df_to_columnar writes fractional seconds with a colon-separated UTC offset. SQL++ string comparisons do not normalize these representations: a fractional timestamp sorts after the same-second cutoff because . sorts after +. The point-in-time template also compares source timestamps directly against the synthetic cutoff.
Example: With end_date=2025-07-10T12:00:00.750000+00:00, an event stored as 2025-07-10T12:00:00.500000+00:00 precedes the requested end. The generated upper bound is 2025-07-10T12:00:00+0000, so the event fails the string comparison. If that is the entity's only event in the range, the entity disappears entirely.
Recommended fix: Preserve microseconds in the synthetic timestamp and normalize source timestamps and bounds to comparable temporal values or a consistent canonical representation. Cover fractional cutoffs and exact inclusive boundaries using timestamps in the format written by df_to_columnar.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if entity_df is None: | ||
| return _get_historical_features_without_entity_df( | ||
| config=config, | ||
| feature_views=feature_views, | ||
| feature_refs=feature_refs, | ||
| registry=registry, | ||
| project=project, | ||
| full_feature_names=full_feature_names, | ||
| filter_by_created_timestamp=filter_by_created_timestamp, | ||
| start_date=kwargs.get("start_date"), | ||
| end_date=kwargs.get("end_date"), | ||
| ) |
There was a problem hiding this comment.
🟡 Missing required universal retrieval coverage
The new entity_df is None path has only mocked unit coverage. The component rules require a universal integration case for retrieval changes. Existing entity-less integration cases exclude Couchbase, leaving generated SQL and returned values untested against this backend.
Learn more
The component checklist requires a universal integration test for retrieval changes. The existing basic non-entity integration test runs only for Ray, while historical non-entity retrieval coverage restricts its corresponding case to the file store. The added unit tests inspect generated SQL or supply mocked query results, so they cannot validate SQL++ execution semantics.
Example: A generated cutoff can pass every SQL substring assertion while excluding the latest eligible event when Couchbase executes the query.
Recommended fix: Add a universal integration case enabled for Couchbase that retrieves without an entity dataframe and asserts actual entity keys, feature values, and timestamps. Include inclusive date boundaries and field mappings, and run the required local integration suite.
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 #7188 +/- ##
==========================================
+ Coverage 53.63% 53.78% +0.14%
==========================================
Files 462 462
Lines 58537 58563 +26
Branches 8632 8636 +4
==========================================
+ Hits 31397 31498 +101
+ Misses 25005 24923 -82
- Partials 2135 2142 +7
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
…ty tests Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
What this PR does / why we need it:
Couchbase Columnar didn't support entity-less historical retrieval.
CouchbaseColumnarOfflineStore.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:start_dateandend_date, combined withUNION ALLand deduplicated withSELECT DISTINCT.end_date, so each entity gets its latest feature values within the TTL.Details:
MULTIPLE_FEATURE_VIEW_POINT_IN_TIME_JOINtemplate. No entity collection is created, so there is nothing to upload or drop.custmapped tocustomer_idbecomescust AS customer_id. Query-based sources are already wrapped in parentheses byget_table_query_string.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.normalize_timestamp, the same UTC string formatpull_latest_from_table_or_queryuses to filter source data.start_dateandend_dateget their defaults fromcompute_non_entity_date_range, like in the other stores.filter_by_created_timestamp,full_feature_namesand on-demand feature views work as they do in entity-df mode.Docs: the Couchbase offline store reference now describes the mode. Couchbase Columnar 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 #5836
Checks
git commit -s)Testing Strategy
Unit tests (
tests/unit/infra/offline_stores/contrib/couchbase_offline_store/test_couchbase_non_entity_mode.py) cover:nullfilling across feature views, skipping feature views without entities, the single-row case, and UTC conversion;get_historical_featuresflow: no upload and no query before execution, final column list, parsing of theevent_timestampcolumn, metadata,start_datedefault, andfilter_by_created_timestamp;The new tests fail on
master.ruff check,ruff format --checkandmypyoncouchbase.pyare clean.Manual end-to-end test: I ran the generated SQL++ on the Analytics service of
couchbase/server:enterprise-7.6.5(the same SQL++ engine as Columnar), using query-based sources over inline documents:end_datewas ignored, an entity whose only event was older than the TTL gotnullfeatures, and an entity with no events in the range was left out.full_feature_names=True.filter_by_created_timestamp=True.end_date:start_datedefaulted toend_dateminus the largest TTL.Misc