Skip to content

Commit 7898480

Browse files
authored
[sql_server] Implement columnation and timely related traits for SQL Server's LSN (#32061)
Fairly straight forward PR, there are a few traits for `columnation` (columnar storage) and `timely` that need to be implemented for `mz_sql_server_util::cdc::Lsn` since `Lsn` is what we use for progress tracking. ### Motivation Progress towards MaterializeInc/database-issues#8762 ### Checklist - [ ] This PR has adequate test coverage / QA involvement has been duly considered. ([trigger-ci for additional test/nightly runs](https://trigger-ci.dev.materialize.com/)) - [ ] This PR has an associated up-to-date [design doc](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/README.md), is a design doc ([template](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/00000000_template.md)), or is sufficiently small to not require a design. <!-- Reference the design in the description. --> - [ ] If this PR evolves [an existing `$T ⇔ Proto$T` mapping](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/command-and-response-binary-encoding.md) (possibly in a backwards-incompatible way), then it is tagged with a `T-proto` label. - [ ] 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](MaterializeInc/cloud#5021)). <!-- Ask in #team-cloud on Slack if you need help preparing the cloud PR. --> - [ ] If this PR includes major [user-facing behavior changes](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/guide-changes.md#what-changes-require-a-release-note), I have pinged the relevant PM to schedule a changelog post.
1 parent 22b8308 commit 7898480

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

Diff for: Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/sql-server-util/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ workspace = true
1313
anyhow = "1.0.66"
1414
async-stream = "0.3.3"
1515
chrono = { version = "0.4.39", default-features = false, features = ["std"] }
16+
columnation = "0.1.0"
1617
dec = "0.4.8"
1718
derivative = "2.2.0"
1819
futures = "0.3.31"
20+
hex = "0.4.3"
1921
mz-ore = { path = "../ore", features = ["async"] }
2022
mz-proto = { path = "../proto" }
2123
mz-repr = { path = "../repr" }
@@ -32,6 +34,7 @@ tiberius = { version = "0.12", features = [
3234
"sql-browser-tokio",
3335
"tds73",
3436
], default-features = false }
37+
timely = "0.20.0"
3538
tokio = { version = "1.44.1", features = ["net"] }
3639
tokio-stream = "0.1.17"
3740
tokio-util = { version = "0.7.4", features = ["compat"] }
@@ -40,7 +43,6 @@ uuid = "1.16.0"
4043
workspace-hack = { version = "0.0.0", path = "../workspace-hack", optional = true }
4144

4245
[dev-dependencies]
43-
hex = "0.4.3"
4446
tracing-subscriber = "0.3.19"
4547

4648
[build-dependencies]

Diff for: src/sql-server-util/src/cdc.rs

+50
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,56 @@ impl TryFrom<&[u8]> for Lsn {
279279
}
280280
}
281281

282+
impl fmt::Display for Lsn {
283+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
284+
write!(f, "{}", hex::encode(&self.0[..]))
285+
}
286+
}
287+
288+
impl columnation::Columnation for Lsn {
289+
type InnerRegion = columnation::CopyRegion<Lsn>;
290+
}
291+
292+
impl timely::progress::Timestamp for Lsn {
293+
// No need to describe complex summaries.
294+
type Summary = ();
295+
296+
fn minimum() -> Self {
297+
Lsn(Default::default())
298+
}
299+
}
300+
301+
impl timely::progress::PathSummary<Lsn> for () {
302+
fn results_in(&self, src: &Lsn) -> Option<Lsn> {
303+
Some(*src)
304+
}
305+
306+
fn followed_by(&self, _other: &Self) -> Option<Self> {
307+
Some(())
308+
}
309+
}
310+
311+
impl timely::progress::timestamp::Refines<()> for Lsn {
312+
fn to_inner(_other: ()) -> Self {
313+
use timely::progress::Timestamp;
314+
Self::minimum()
315+
}
316+
fn to_outer(self) -> () {}
317+
318+
fn summarize(_path: <Self as timely::progress::Timestamp>::Summary) -> () {}
319+
}
320+
321+
impl timely::order::PartialOrder for Lsn {
322+
fn less_equal(&self, other: &Self) -> bool {
323+
self <= other
324+
}
325+
326+
fn less_than(&self, other: &Self) -> bool {
327+
self < other
328+
}
329+
}
330+
impl timely::order::TotalOrder for Lsn {}
331+
282332
/// Structured format of an [`Lsn`].
283333
///
284334
/// Note: The derived impl of [`PartialOrd`] and [`Ord`] relies on the field

0 commit comments

Comments
 (0)