Table

Struct Table 

Source
pub struct Table {
Show 24 fields pub id: Uuid, pub name: String, pub columns: Vec<Column>, pub database_type: Option<DatabaseType>, pub catalog_name: Option<String>, pub schema_name: Option<String>, pub medallion_layers: Vec<MedallionLayer>, pub scd_pattern: Option<SCDPattern>, pub data_vault_classification: Option<DataVaultClassification>, pub modeling_level: Option<ModelingLevel>, pub tags: Vec<Tag>, pub odcl_metadata: HashMap<String, Value>, pub owner: Option<String>, pub sla: Option<Vec<SlaProperty>>, pub contact_details: Option<ContactDetails>, pub infrastructure_type: Option<InfrastructureType>, pub notes: Option<String>, pub position: Option<Position>, pub yaml_file_path: Option<String>, pub drawio_cell_id: Option<String>, pub quality: Vec<HashMap<String, Value>>, pub errors: Vec<HashMap<String, Value>>, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>,
}
Expand description

Table model representing a database table or data contract

A table represents a structured data entity with columns, metadata, and relationships. Tables can be imported from various formats (SQL, ODCS, JSON Schema, etc.) and exported to multiple formats.

§Example

use data_modelling_core::models::{Table, Column};

let table = Table::new(
    "users".to_string(),
    vec![
        Column::new("id".to_string(), "INT".to_string()),
        Column::new("name".to_string(), "VARCHAR(100)".to_string()),
    ],
);

§Example with Metadata (Data Flow Node)

use data_modelling_core::models::{Table, Column, InfrastructureType, ContactDetails, SlaProperty};
use serde_json::json;

let mut table = Table::new(
    "user_events".to_string(),
    vec![Column::new("id".to_string(), "UUID".to_string())],
);
table.owner = Some("Data Engineering Team".to_string());
table.infrastructure_type = Some(InfrastructureType::Kafka);
table.contact_details = Some(ContactDetails {
    email: Some("team@example.com".to_string()),
    phone: None,
    name: Some("Data Team".to_string()),
    role: Some("Data Owner".to_string()),
    other: None,
});
table.sla = Some(vec![SlaProperty {
    property: "latency".to_string(),
    value: json!(4),
    unit: "hours".to_string(),
    description: Some("Data must be available within 4 hours".to_string()),
    element: None,
    driver: Some("operational".to_string()),
    scheduler: None,
    schedule: None,
}]);
table.notes = Some("User interaction events from web application".to_string());

Fields§

§id: Uuid

Unique identifier for the table (UUIDv4)

§name: String

Table name (must be unique within database_type/catalog/schema scope)

§columns: Vec<Column>

List of columns in the table

§database_type: Option<DatabaseType>

Database type (PostgreSQL, MySQL, etc.) if applicable

§catalog_name: Option<String>

Catalog name (database name in some systems)

§schema_name: Option<String>

Schema name (namespace within catalog)

§medallion_layers: Vec<MedallionLayer>

Medallion architecture layers (Bronze, Silver, Gold)

§scd_pattern: Option<SCDPattern>

Slowly Changing Dimension pattern (Type 1, Type 2, etc.)

§data_vault_classification: Option<DataVaultClassification>

Data Vault classification (Hub, Link, Satellite)

§modeling_level: Option<ModelingLevel>

Modeling level (Conceptual, Logical, Physical)

§tags: Vec<Tag>

Tags for categorization and filtering (supports Simple, Pair, and List formats)

§odcl_metadata: HashMap<String, Value>

ODCL/ODCS metadata (legacy format support)

§owner: Option<String>

Owner information (person, team, or organization name) for Data Flow nodes

§sla: Option<Vec<SlaProperty>>

SLA (Service Level Agreement) information (ODCS-inspired but lightweight format)

§contact_details: Option<ContactDetails>

Contact details for responsible parties

§infrastructure_type: Option<InfrastructureType>

Infrastructure type (hosting platform, service, or tool) for Data Flow nodes

§notes: Option<String>

Additional notes and context for Data Flow nodes

§position: Option<Position>

Canvas position for visual representation

§yaml_file_path: Option<String>

Path to YAML file if loaded from file system

§drawio_cell_id: Option<String>

Draw.io cell ID for diagram integration

§quality: Vec<HashMap<String, Value>>

Quality rules and checks

§errors: Vec<HashMap<String, Value>>

Validation errors and warnings

§created_at: DateTime<Utc>

Creation timestamp

§updated_at: DateTime<Utc>

Last update timestamp

Implementations§

Source§

impl Table

Source

pub fn new(name: String, columns: Vec<Column>) -> Table

Create a new table with the given name and columns

§Arguments
  • name - The table name (must be valid according to naming conventions)
  • columns - Vector of columns for the table
§Returns

A new Table instance with a generated UUIDv4 ID and current timestamps.

§Example
use data_modelling_core::models::{Table, Column};

let table = Table::new(
    "users".to_string(),
    vec![Column::new("id".to_string(), "INT".to_string())],
);
Source

pub fn get_unique_key( &self, ) -> (Option<String>, String, Option<String>, Option<String>)

Get the unique key tuple for this table

Returns a tuple of (database_type, name, catalog_name, schema_name) that uniquely identifies this table within its scope. Used for detecting naming conflicts.

§Returns

A tuple containing the database type (as string), name, catalog name, and schema name.

Source

pub fn generate_id( _name: &str, _database_type: Option<&DatabaseType>, _catalog_name: Option<&str>, _schema_name: Option<&str>, ) -> Uuid

Generate a UUIDv4 for a new table id.

Note: params are retained for backward-compatibility with previous deterministic-v5 API.

Source

pub fn from_table_data(table_data: &TableData) -> Table

Create a Table from imported TableData.

Converts the import format (TableData) to the internal Table model. This is used when exporting ODCS YAML directly to PDF/Markdown.

§Arguments
  • table_data - The imported table data from ODCS parser
§Returns

A new Table instance populated from the import data

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

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 Table

Source§

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

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

impl<'de> Deserialize<'de> for Table

Source§

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

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

impl PartialEq for Table

Source§

fn eq(&self, other: &Table) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Table

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Table

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnwindSafe for Table

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> 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> 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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,