Skip to content

Conversation

@piotrrzysko
Copy link
Member

Description

Follow-up to #27356

The first two commits are from that PR.

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

This is a preparatory change that allows connectors to store information
about the WHEN STALE behavior. The option cannot yet be used in practice,
as execution will still fail with a NOT_SUPPORTED error.
Behavior:
- `FAIL` - If the MV is stale, queries referencing it will fail. Analysis
of the underlying query is never performed while querying the MV.
- `INLINE` - Preserves the current behavior. Even if the MV is stale, it
is expanded like a logical view, and the underlying query is analyzed.

Motivation:
- Avoid analyzing the underlying query every time, which can be costly
when it references many tables.
- Allow using fresh MVs even when some data sources are temporarily
unavailable.
@cla-bot cla-bot bot added the cla-signed label Nov 28, 2025
@github-actions github-actions bot added iceberg Iceberg connector lakehouse labels Nov 28, 2025
.matches(initialResults);
assertThat(query(futureSession, "TABLE " + viewName))
.hasPlan(readFromBaseTables)
.matches(updatedResults);
Copy link
Member Author

Choose a reason for hiding this comment

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

@findepi I'm moving your comment to this PR so it doesn’t get lost:

The MV has GRACE PERIOD INTERVAL '1' HOUR.
The GRACE is defined earlier in the MV definition and should take precedence. I.e. we should keep querying the MV storage when it's known to be stale but grace period did not elapse.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe that in this case we should query the base tables, because we use a session (futureSession) that started after the grace period expired.

@findepi findepi changed the title Support WHEN STALE in analyzer Support MATERIALIZED VIEW WHEN STALE in analyzer Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant