Skip to content

feat: Retrieve historical features from Couchbase Columnar without an entity dataframe - #7188

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

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

Conversation

@NopeCharon

@NopeCharon NopeCharon commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Couchbase Columnar didn't support entity-less historical retrieval. CouchbaseColumnarOfflineStore.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: CouchbaseColumnarOfflineStore.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 the distinct join keys found in each feature view source between start_date and end_date, combined with UNION ALL and deduplicated with SELECT DISTINCT.
  • 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 SQL++ MULTIPLE_FEATURE_VIEW_POINT_IN_TIME_JOIN template. No entity collection is created, so there is nothing to upload or drop.
  • 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 sources are already wrapped in parentheses by get_table_query_string.
  • 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.
  • Timestamps are written with normalize_timestamp, the same UTC string format pull_latest_from_table_or_query uses to filter source data.
  • 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.
  • Entity-df retrieval (pandas or SQL++) is unchanged.

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

  • 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/couchbase_offline_store/test_couchbase_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 query before execution, final column list, parsing of the event_timestamp column, 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. ruff check, ruff format --check and mypy on couchbase.py are 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:

  • One feature view: the latest value per entity was returned, a duplicate event timestamp was resolved by the created timestamp, an event after end_date was ignored, an entity whose only event was older than the TTL got null features, and an entity with no events in the range was left out.
  • Two feature views with disjoint entities, one with a field-mapped source, with full_feature_names=True.
  • A feature view without entities, on its own and together with an entity feature view.
  • filter_by_created_timestamp=True.
  • A date range without events returned no rows.
  • Only end_date: start_date defaulted to end_date minus the largest TTL.

Misc


Devin Review

… 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>
@NopeCharon
NopeCharon requested a review from a team as a code owner November 19, 2026 22:40

@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 2 potential issues.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +574 to +575
start_timestamp = normalize_timestamp(start_date)
end_timestamp = normalize_timestamp(end_date)

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.

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

Devin Review


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

Comment on lines +157 to +168
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"),
)

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

Devin Review


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

@codecov-commenter

codecov-commenter commented Nov 19, 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.78%. Comparing base (1d6cfb4) to head (fa938c7).
❗ 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    #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     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.37% <100.00%> (+0.15%) ⬆️
Files with missing lines Coverage Δ
...tores/contrib/couchbase_offline_store/couchbase.py 65.81% <100.00%> (+35.04%) ⬆️

... 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 1d6cfb4...fa938c7. 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.

…ty tests

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

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.

Couchbase Columnar - historical retrieval without entity dataframe

2 participants