TableMetadata

Struct TableMetadata 

Source
pub struct TableMetadata {
    pub table_id: u32,
    pub name: String,
    pub catalog_name: String,
    pub namespace_name: String,
    pub table_type: TableType,
    pub data_source_format: DataSourceFormat,
    pub columns: Vec<ColumnMetadata>,
    pub primary_key: Option<Vec<String>>,
    pub storage_options: StorageOptions,
    pub storage_location: Option<String>,
    pub comment: Option<String>,
    pub properties: HashMap<String, String>,
}
Expand description

Metadata for a table in the catalog.

Contains the table ID, name, column definitions, and optional primary key constraint.

§Examples

use alopex_sql::catalog::{TableMetadata, ColumnMetadata};
use alopex_sql::planner::types::ResolvedType;

let columns = vec![
    ColumnMetadata::new("id", ResolvedType::Integer)
        .with_primary_key(true)
        .with_not_null(true),
    ColumnMetadata::new("name", ResolvedType::Text)
        .with_not_null(true),
];

let table = TableMetadata::new("users", columns)
    .with_primary_key(vec!["id".to_string()]);

assert_eq!(table.name, "users");
assert!(table.get_column("id").is_some());
assert_eq!(table.column_names(), vec!["id", "name"]);

Fields§

§table_id: u32

Unique table ID assigned by the catalog.

§name: String

Table name.

§catalog_name: String

Catalog name.

§namespace_name: String

Namespace name.

§table_type: TableType

Table type.

§data_source_format: DataSourceFormat

Data source format.

§columns: Vec<ColumnMetadata>

Column definitions (order is preserved).

§primary_key: Option<Vec<String>>

Primary key columns (supports composite keys).

§storage_options: StorageOptions

Storage configuration (row/columnar, compression, row group sizing).

§storage_location: Option<String>

Storage location path.

§comment: Option<String>

Comment.

§properties: HashMap<String, String>

Custom properties.

Implementations§

Source§

impl TableMetadata

Source

pub fn new(name: impl Into<String>, columns: Vec<ColumnMetadata>) -> Self

Create a new table metadata with the given name and columns.

The table_id defaults to 0; use with_table_id() to set it, or it will be assigned by the Catalog when the table is created.

Source

pub fn with_table_id(self, table_id: u32) -> Self

Set the table ID.

Source

pub fn with_primary_key(self, columns: Vec<String>) -> Self

Set the primary key columns.

Source

pub fn get_column(&self, name: &str) -> Option<&ColumnMetadata>

Get a column by name.

Returns None if the column doesn’t exist.

§Examples
use alopex_sql::catalog::{TableMetadata, ColumnMetadata};
use alopex_sql::planner::types::ResolvedType;

let table = TableMetadata::new("users", vec![
    ColumnMetadata::new("id", ResolvedType::Integer),
    ColumnMetadata::new("name", ResolvedType::Text),
]);

assert!(table.get_column("id").is_some());
assert!(table.get_column("unknown").is_none());
Source

pub fn get_column_index(&self, name: &str) -> Option<usize>

Get the index of a column by name.

Returns None if the column doesn’t exist.

Source

pub fn column_names(&self) -> Vec<&str>

Get a list of all column names in definition order.

§Examples
use alopex_sql::catalog::{TableMetadata, ColumnMetadata};
use alopex_sql::planner::types::ResolvedType;

let table = TableMetadata::new("users", vec![
    ColumnMetadata::new("id", ResolvedType::Integer),
    ColumnMetadata::new("name", ResolvedType::Text),
    ColumnMetadata::new("age", ResolvedType::Integer),
]);

assert_eq!(table.column_names(), vec!["id", "name", "age"]);
Source

pub fn column_count(&self) -> usize

Get the number of columns in the table.

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 From<&TableMetadata> for PersistedTableMeta

Source§

fn from(value: &TableMetadata) -> Self

Converts to this type from the input type.
Source§

impl From<&TableMetadata> for TableFqn

Source§

fn from(value: &TableMetadata) -> Self

Converts to this type from the input type.
Source§

impl From<PersistedTableMeta> for TableMetadata

Source§

fn from(value: PersistedTableMeta) -> Self

Converts to this type from the input type.

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> 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> 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,