Skip to main content

TableMetadata

Struct TableMetadata 

Source
pub struct TableMetadata {
Show 15 fields pub table_uuid: Uuid, pub format_version: i32, pub location: String, pub last_sequence_number: i64, pub last_updated_ms: i64, pub last_column_id: i32, pub current_schema_id: i32, pub schemas: Vec<Schema>, pub default_spec_id: i32, pub partition_specs: Vec<PartitionSpec>, pub current_snapshot_id: Option<i64>, pub snapshots: Vec<Snapshot>, pub snapshot_log: Vec<SnapshotLogEntry>, pub properties: HashMap<String, String>, pub metrics: TableMetrics,
}
Expand description

The root metadata object for a SuperTable table.

This struct contains all information needed to understand the current state of a table, including its schema history, partition specs, snapshots, and properties.

§Concurrency

The last_sequence_number field is used for optimistic concurrency control. Each operation that modifies the table increments this counter, allowing the catalog to detect and reject conflicting concurrent updates.

§Example

use supercore::metadata::TableMetadata;
use supercore::schema::{Schema, Field, Type};

let schema = Schema {
    schema_id: 0,
    fields: vec![
        Field { id: 1, name: "id".into(), required: true, field_type: Type::Long },
        Field { id: 2, name: "data".into(), required: false, field_type: Type::String },
    ],
};

let metadata = TableMetadata::builder("s3://bucket/my_table", schema)
    .with_property("write.format.default", "parquet")
    .build();

Fields§

§table_uuid: Uuid

The unique identifier for this table (UUID v4).

§format_version: i32

The format version of this metadata file. Used for forward/backward compatibility checks.

§location: String

The base location of the table (e.g., s3://bucket/table). All data and metadata files are stored relative to this location.

§last_sequence_number: i64

Monotonically increasing sequence number for optimistic concurrency. Incremented on each metadata update operation.

§last_updated_ms: i64

Timestamp of the last update in milliseconds since epoch (UTC).

§last_column_id: i32

The highest assigned column ID across all schemas. Used to ensure new columns get unique IDs during schema evolution.

§current_schema_id: i32

The ID of the current (active) schema.

§schemas: Vec<Schema>

List of all schemas, forming the schema history. Schemas are immutable once added.

§default_spec_id: i32

The ID of the default partition spec.

§partition_specs: Vec<PartitionSpec>

List of partition specs.

§current_snapshot_id: Option<i64>

The ID of the current snapshot, or None if the table is empty.

§snapshots: Vec<Snapshot>

List of all snapshots, forming the table’s history.

§snapshot_log: Vec<SnapshotLogEntry>

Log of snapshot changes for auditing and time travel.

§properties: HashMap<String, String>

User-defined table properties. Common properties include write format, compression, etc.

§metrics: TableMetrics

Aggregate table metrics.

Implementations§

Source§

impl TableMetadata

Source

pub fn builder( location: impl Into<String>, schema: Schema, ) -> TableMetadataBuilder

Creates a new TableMetadataBuilder.

Source

pub fn current_schema(&self) -> &Schema

Returns the current schema.

§Panics

Panics if the schema list is empty or the current schema ID is invalid. This should never happen with properly constructed metadata.

Source

pub fn current_snapshot(&self) -> Option<&Snapshot>

Returns the current snapshot, if any.

Source

pub fn snapshot(&self, snapshot_id: i64) -> Option<&Snapshot>

Returns a snapshot by its ID.

Source

pub fn snapshot_at(&self, timestamp_ms: i64) -> Option<&Snapshot>

Returns the snapshot that was current at the given timestamp.

This enables time-travel queries by finding the most recent snapshot that was committed before the specified timestamp.

Source

pub fn schema(&self, schema_id: i32) -> Option<&Schema>

Returns the schema with the given ID.

Source

pub fn current_partition_spec(&self) -> Option<&PartitionSpec>

Returns the current partition spec.

Source

pub fn add_partition_spec(&mut self, spec: PartitionSpec)

Adds a new partition spec and sets it as the default.

Source

pub fn increment_sequence(&mut self)

Increments the sequence number and updates the timestamp.

This should be called before committing any metadata update.

Source

pub fn add_snapshot(&mut self, snapshot: Snapshot)

Adds a new snapshot to the table and makes it current.

This also creates a snapshot log entry for auditing.

Source

pub fn add_schema(&mut self, schema: Schema)

Adds a new schema to the table.

The schema ID must be unique. Use next_schema_id() to generate one.

Source

pub fn next_schema_id(&self) -> i32

Returns the next available schema ID.

Source

pub fn next_column_id(&self) -> i32

Returns the next available column ID.

Source

pub fn next_snapshot_id(&self) -> i64

Returns the next available snapshot ID.

Source

pub fn set_current_schema( &mut self, schema_id: i32, ) -> Result<(), MetadataError>

Sets the current schema by ID.

§Errors

Returns an error if the schema ID doesn’t exist.

Source

pub fn rollback_to(&mut self, snapshot_id: i64) -> Result<(), MetadataError>

Rolls back the table to a previous snapshot.

This creates a new snapshot log entry pointing to the old snapshot, effectively making it current again without removing history.

§Errors

Returns an error if the snapshot ID doesn’t exist.

Source

pub fn update_metrics( &mut self, added: &[DataFile], deleted_paths: &HashSet<String>, )

Updates the aggregate metrics based on added and deleted files.

Trait Implementations§

Source§

impl Clone for TableMetadata

Source§

fn clone(&self) -> TableMetadata

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TableMetadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TableMetadata

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TableMetadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T