[poc] CREATE MATERIALIZED VIEW ... REPLACING #34177
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I hacked together a poc exploring the implementation effort of modeling replacement MVs as materialized views, instead of a separate "replacement" item type. The benefit would be to keep the SQL surface small.
This is very hacky, but show the general idea. We use the storage controller's existing capability to specify multiple collections backed by the same shard through a "primary" relationship. This lets us create a second read-only MV that points at the same shard as the existing MV. Both MVs can co-exist, you can select from both of them, and dropping the replacement works.
There is also still some strangeness. Because I've not defined a SQL-level dependency, you can drop the "leader" MV without dropping the replacement. The strange part is that the replacement's frontier keeps advancing even though it is in read-only mode (and no updates are flowing through from the source either). What is advancing the frontier??
Also, I haven't implemented the "apply" step. Assumption is that it won't be harder to implement than in the "replacement" item type version, but that might be wrong.
Motivation
Tips for reviewer
Checklist
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel.