Skip to content

Conversation

@ceesem
Copy link
Collaborator

@ceesem ceesem commented Jul 7, 2025

When a materialization version is set or requested that is currently expired, fall back on a live_query using the timestamp.

Currently this uses live_query instead of live_live_query to follow synapse_query behavior, although this should probably all be replaced with live query. The main difficulty there is remapping all of the join and query logic because every function has a different approach to this. My intuition is that it would be better to do inside the live_query function itself, and we change the default behavior over to the current weirdly named live_live_query.

We can discuss if this should also be done in this pull request.

@codecov
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

Attention: Patch coverage is 70.64220% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
caveclient/materializationengine.py 67.34% 32 Missing ⚠️
Files with missing lines Coverage Δ
caveclient/tools/testing.py 92.61% <100.00%> (+0.41%) ⬆️
tests/conftest.py 100.00% <ø> (ø)
tests/test_materialization.py 94.82% <100.00%> (-0.09%) ⬇️
caveclient/materializationengine.py 63.34% <67.34%> (+0.62%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ceesem ceesem requested a review from Copilot July 7, 2025 19:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a fallback to timestamp-based live queries when a requested materialization version is expired, and adds guards against using expired versions in various query and metadata methods.

  • Adds a cached available_versions property to fetch non-expired materialization versions.
  • Implements a timestamp fallback in query_table for expired versions.
  • Adds expiry validations (raising ValueError) in join_query, get_views, get_view_metadata, get_view_schemas, and query_view, and updates test mocks to cover the new endpoint.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
caveclient/tools/testing.py Extended mock setup with available_versions endpoint and removed stray whitespace.
caveclient/materializationengine.py Introduced available_versions, get_timestamp caching, expiry checks in queries, and timestamp fallback logic.
Comments suppressed due to low confidence (1)

caveclient/tools/testing.py:535

  • Add test cases for the expired-version fallback path to verify that query_table correctly uses the timestamp-based live_query when versions are expired.
            responses.add(

if (
materialization_version not in self.available_versions
and materialization_version is not None
):
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting version validation and fallback logic into a shared helper to reduce duplication and maintain consistent behavior across query methods.

Copilot uses AI. Check for mistakes.

if materialization_version is None:
materialization_version = self.version
if materialization_version not in self.available_versions:
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] In join_query, expired versions raise an error while query_table falls back to a timestamp-based query; consider aligning these behaviors or centralizing the fallback logic.

Copilot uses AI. Check for mistakes.
Comment on lines 2251 to 2255
if version not in self.available_versions:
raise ValueError(
f"Materialization version must not be expired for views. "
f"Available versions: {self.available_versions}"
)
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These expiry checks are duplicated in several methods (get_views, get_view_metadata, etc.); refactor into a common validator to improve maintainability.

Suggested change
if version not in self.available_versions:
raise ValueError(
f"Materialization version must not be expired for views. "
f"Available versions: {self.available_versions}"
)
self.validate_version(version)

Copilot uses AI. Check for mistakes.
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.

2 participants