materialize icon indicating copy to clipboard operation
materialize copied to clipboard

adapter: Refactor `RelationDesc`

Open ParkMyCar opened this issue 1 year ago • 1 comments

This PR refactors RelationDesc to support adding columns to tables, it does a few things:

  1. Creates a RelationDescBuilder and moves a few methods, namely with_column(...) onto the new builder. The goal here was to disambiguate adding a column to a new version of the RelationDesc and the initial construction of a RelationDesc.
  2. Refactors the internals of RelationDesc from a Vec<ColumnName> to a BTreeMap<ColumnIndex, ColumnMetadata>. There are two primary things this enables:
    1. Stable tracking of column positions with ColumnIndex
    2. ColumnMetadata tracks the version at which a column was added and optionally dropped.

Motivation

Progress towards https://github.com/MaterializeInc/materialize/issues/28082

Tips for reviewer

These changes are split into two separate commits:

  1. Adding RelationDescBuilder, this is more or less code movement.
  2. 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$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • [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.

ParkMyCar avatar Aug 26 '24 21:08 ParkMyCar

Risk Score:81 / 100 Bug Hotspots:1 Resilience Coverage:33%

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

shepherdlybot[bot] avatar Aug 26 '24 21:08 shepherdlybot[bot]

@jkosh44 good call with the duplicate columns, it was pretty easy to support that. Updated the comments and added tests!

ParkMyCar avatar Aug 29 '24 13:08 ParkMyCar