Skip to content

Conversation

@antiguru
Copy link
Member

@antiguru antiguru commented Nov 5, 2025

Implement a mechanism to replace materialized views with new definitions. This is a work-in-progress with many rough edges, and not a full implementation.

The PR adds the following syntax:

  • To replace a materialized view, the user creates a replacement:
    CREATE REPLACEMENT mv_replacement FOR MATERIALIZED VIEW mv AS SELECT ...
  • The user then observes hydration progress. At some point, they decide it wasn't a good change after all:
    DROP REPLACEMENT mv_replacement
  • Or, they figure it's a good change and apply it:
    ALTER MATERIALIZED VIEW mv APPLY REPLACEMENT mv_replacement

Caveats

The implementation will come with some properties worth pointing out:

  • Data at a specific time before the write frontier is sealed, and we cannot change it anymore. This means that constant materialized views cannot be changed at all, and refresh-every MVs only after the current write frontier, which is the next refresh moment.

Here's a rough overview of where we stand:

  • Parse CREATE REPLACEMENT
  • Parse DROP REPLCACEMENT
  • Parse ALTER MATERIALIZED VIEW .. APPLY REPLACEMENT
  • Per-object write mode in compute.
  • Schema changes

Change the infrastructure to allow writes to granular per object, instead
of per compute replica. While this isn't strictly needed at the moment,
it'll serve a purpose for altering materialized views where we need to
control whether a materialized view is permitted to write independently of
whether a replica is permitted to write.

Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
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.

1 participant