Skip to main content

UpsertSourceTime

Trait UpsertSourceTime 

Source
pub trait UpsertSourceTime
where for<'a> Ref<'a, Self::Order>: Ord,
{ type Order: Columnar + Clone + Default + Ord + Send + Sync + 'static; // Required method fn upsert_order(&self) -> Self::Order; }
Expand description

Projects a source’s native FromTime to a columnar, totally-ordered key used by the upsert source stash to keep the latest update per (key, time).

The upsert stash is a paged columnar merge batcher; its diff carries this projection rather than the raw FromTime, so the only columnar type the stash needs is Order — never the (possibly structurally complex) source timestamp. This is what keeps the columnar requirement off the generic source-render path: that path only ever needs FromTime: UpsertSourceTime. Only the relative order matters; the value is never read back.

The upsert envelope is rendered for Kafka and the KEY VALUE load generator, so those source times (KafkaTimestamp, MzOffset) project to a real order key. The remaining source times implement the trait only for coherence on the generic render path — their sources never render upsert — so their projection is a panicking guard rather than a real key.

Required Associated Types§

Source

type Order: Columnar + Clone + Default + Ord + Send + Sync + 'static

Columnar order key. Must order consistently with the source time it is projected from.

Required Methods§

Source

fn upsert_order(&self) -> Self::Order

Project the source time onto its order key.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl UpsertSourceTime for GtidPartition

Source§

impl UpsertSourceTime for KafkaTimestamp

Source§

type Order = (i64, u64)

Per-record Kafka source times are exact singletons (a single partition at a single offset; see the source reader), and KafkaTimestamp’s derived Ord is lexicographic on (partition, offset), so this flat projection is order-preserving. RangeBound’s infinities map to the i64 extrema to remain order-consistent for any non-singleton bound.

Source§

fn upsert_order(&self) -> (i64, u64)

Source§

impl UpsertSourceTime for Lsn

Source§

impl UpsertSourceTime for MzOffset

Load-generator (and Postgres) source time. The KEY VALUE load generator is the one non-Kafka source that renders the upsert envelope (see apply_source_envelope_encoding in the planner), so this projects to the record offset: offsets increase with each update, so “max order wins” is exactly “latest update wins” for dedup.

Implementors§