adapter: Refactor `RelationDesc`
This PR refactors RelationDesc to support adding columns to tables, it does a few things:
- Creates a
RelationDescBuilderand moves a few methods, namelywith_column(...)onto the new builder. The goal here was to disambiguate adding a column to a new version of theRelationDescand the initial construction of aRelationDesc. - Refactors the internals of
RelationDescfrom aVec<ColumnName>to aBTreeMap<ColumnIndex, ColumnMetadata>. There are two primary things this enables:- Stable tracking of column positions with
ColumnIndex -
ColumnMetadatatracks the version at which a column was added and optionally dropped.
- Stable tracking of column positions with
Motivation
Progress towards https://github.com/MaterializeInc/materialize/issues/28082
Tips for reviewer
These changes are split into two separate commits:
- Adding
RelationDescBuilder, this is more or less code movement. - Refactoring the internals of
RelationDesc. This shouldn't cause any behavior changes but is a decent amount of changes.
Checklist
- [x] This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
- [x] This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
- [x] If this PR evolves an existing
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel. - [x] If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
- [x] If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.
Mitigations
Completing required mitigations increases Resilience Coverage.
- [x] (Required) Code Review
🔍 Detected - [ ] (Required) Feature Flag
- [x] (Required) Integration Test
🔍 Detected - [ ] (Required) Observability
- [ ] (Required) QA Review
- [ ] (Required) Run Nightly Tests
- [x] Unit Test
🔍 Detected
Risk Summary:
The pull request has a high risk score of 81, primarily driven by the predictors "Sum Bug Reports Of Files" and "Delta of Executable Lines," along with modifications in one file hotspot. Historically, PRs with these predictors are 109% more likely to cause a bug than the repository baseline. Notably, the observed bug trend in the repository is decreasing.
Note: The risk score is not based on semantic analysis but on historical predictors of bug occurrence in the repository. The attributes above were deemed the strongest predictors based on that history. Predictors and the score may change as the PR evolves in code, time, and review activity.
Bug Hotspots: What's This?
| File | Percentile |
|---|---|
| ../durable/persist.rs | 98 |
@jkosh44 good call with the duplicate columns, it was pretty easy to support that. Updated the comments and added tests!