Skip to content

Conversation

@sakce
Copy link
Contributor

@sakce sakce commented Dec 8, 2025

Problem

When an endpoint's materialization changes (due to a new version or a materialization run), the existing cache might contain stale results, leading to users seeing outdated data. The cache needs to be invalidated if it predates these updates.

Changes

  • Introduced _get_cache_age_for_version to dynamically calculate the effective cache age for inline endpoints, ensuring cached results older than the current version's creation are considered stale.
  • Introduced _get_cache_age_for_materialization to set the effective cache age for materialized endpoints based on the last_run_at of the associated DataWarehouseSavedQuery, ensuring cached results older than the last materialization run are considered stale.
  • Updated _execute_inline_endpoint and _execute_materialized_endpoint to use these dynamically calculated cache_age_seconds during query execution.

How did you test this code?

Added new comprehensive unit tests in products/endpoints/backend/tests/test_endpoint_materialization.py:

  • test_cache_invalidated_on_version_change: Verifies cache invalidation when a new endpoint version is created.
  • test_cache_invalidated_on_materialization_update: Verifies cache invalidation when a materialized table is updated.
  • test_version_cache_age_respects_endpoint_cache_setting: Ensures version-based cache age does not exceed the endpoint's configured cache_age_seconds.
    All existing and new tests pass.

Changelog: (features only) Is this feature complete?

No


Slack Thread

Open in Cursor Open in Web

Co-authored-by: sakovic.fx <sakovic.fx@gmail.com>
@cursor
Copy link

cursor bot commented Dec 8, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

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.

3 participants