Skip to main content

DeltaTable

Struct DeltaTable 

Source
pub struct DeltaTable {
    pub state: Option<DeltaTableState>,
    pub config: DeltaTableConfig,
    /* private fields */
}
Expand description

In memory representation of a Delta Table

A DeltaTable is a purely logical concept that represents a dataset that can ewvolve over time. To attain concrete information about a table a snapshot need to be loaded. Most commonly this is the latest state of the tablem but may also loaded for a specific version or point in time.

Fields§

§state: Option<DeltaTableState>

The state of the table as of the most recent loaded Delta log entry.

§config: DeltaTableConfig

the load options used during load

Implementations§

Source§

impl DeltaTable

Source

pub async fn try_from_url(uri: Url) -> Result<DeltaTable, DeltaTableError>

Create a new DeltaOps instance, operating on DeltaTable at given URL.

use deltalake_core::DeltaTable;
use url::Url;

async {
    let url = Url::parse("memory:///").unwrap();
    let ops = DeltaTable::try_from_url(url).await.unwrap();
};
Source

pub async fn try_from_url_with_storage_options( uri: Url, storage_options: HashMap<String, String>, ) -> Result<DeltaTable, DeltaTableError>

Create a DeltaTable instance from URL with storage options

Source

pub fn create(&self) -> CreateBuilder

Source

pub fn restore(self) -> RestoreBuilder

Source

pub fn vacuum(self) -> VacuumBuilder

Vacuum stale files from delta table

Source

pub fn filesystem_check(self) -> FileSystemCheckBuilder

Audit active files with files present on the filesystem

Source

pub fn add_feature(self) -> AddTableFeatureBuilder

Enable a table feature for a table

Source

pub fn set_tbl_properties(self) -> SetTablePropertiesBuilder

Set table properties

Source

pub fn add_columns(self) -> AddColumnBuilder

Add new columns

Source

pub fn update_field_metadata(self) -> UpdateFieldMetadataBuilder

Update field metadata

Source

pub fn update_table_metadata(self) -> UpdateTableMetadataBuilder

Update table metadata

Source

pub fn generate(self) -> GenerateBuilder

Generate a symlink_format_manifest for other engines

Source§

impl DeltaTable

Source

pub fn scan_table(&self) -> LoadBuilder

Source

pub fn scan_cdf(self) -> CdfLoadBuilder

Load a table with CDF Enabled

Source

pub fn write( self, batches: impl IntoIterator<Item = RecordBatch>, ) -> WriteBuilder

Source

pub fn optimize<'a>(self) -> OptimizeBuilder<'a>

Audit active files with files present on the filesystem

Source

pub fn delete(self) -> DeleteBuilder

Delete data from Delta table

Source

pub fn update(self) -> UpdateBuilder

Update data from Delta table

Source

pub fn merge<E>(self, source: DataFrame, predicate: E) -> MergeBuilder
where E: Into<Expression>,

Update data from Delta table

Source

pub fn add_constraint(self) -> ConstraintBuilder

Add a check constraint to a table

Source

pub fn drop_constraints(self) -> DropConstraintBuilder

Drops constraints from a table

Source§

impl DeltaTable

Source

pub fn new(log_store: Arc<dyn LogStore>, config: DeltaTableConfig) -> DeltaTable

Create a new Delta Table struct without loading any data from backing storage.

NOTE: This is for advanced users. If you don’t know why you need to use this method, please call one of the open_table helper methods instead.

Source

pub fn new_in_memory() -> DeltaTable

Create a new DeltaTable instance, backed by an un-initialized in memory table

Using this will not persist any changes beyond the lifetime of the table object. The main purpose of in-memory tables is for use in testing.

use deltalake_core::DeltaTable;
let table = DeltaTable::new_in_memory();
Source

pub fn object_store(&self) -> Arc<dyn ObjectStore>

get a shared reference to the delta object store

Source

pub async fn verify_deltatable_existence(&self) -> Result<bool, DeltaTableError>

Check if the DeltaTable exists

Source

pub fn table_url(&self) -> &Url

The URI of the underlying data

Source

pub fn log_store(&self) -> Arc<dyn LogStore>

get a shared reference to the log store

Source

pub async fn get_latest_version(&self) -> Result<u64, DeltaTableError>

returns the latest available version of the table

Source

pub fn version(&self) -> Option<u64>

Currently loaded version of the table - if any.

This will return the latest version of the table if it has been loaded. Returns None if the table has not been loaded.

Source

pub async fn load(&mut self) -> Result<(), DeltaTableError>

Load DeltaTable with data from latest checkpoint

Source

pub async fn update_state(&mut self) -> Result<(), DeltaTableError>

Updates the DeltaTable to the most recent state committed to the transaction log by loading the last checkpoint and incrementally applying each version since.

Source

pub async fn update_incremental( &mut self, max_version: Option<u64>, ) -> Result<(), DeltaTableError>

Updates the DeltaTable by incrementally applying newer versions, optionally bounded by max_version.

This API is forward-only. Use DeltaTable::load_version to load an older version.

Source

pub async fn load_version( &mut self, version: u64, ) -> Result<(), DeltaTableError>

Loads the DeltaTable state for the given version.

Source

pub async fn history( &self, limit: Option<usize>, ) -> Result<impl Iterator<Item = CommitInfo> + use<>, DeltaTableError>

Returns provenance information, including the operation, user, and so on, for each write to a table. The table history retention is based on the logRetentionDuration property of the Delta Table, 30 days by default. If limit is given, this returns the information of the latest limit commits made to this table. Otherwise, it returns all commits from the earliest commit.

Source

pub fn get_active_add_actions_by_partitions( &self, filters: &[PartitionFilter], ) -> Pin<Box<dyn Stream<Item = Result<LogicalFileView, DeltaTableError>> + Send + '_>>

Stream all logical files matching the provided PartitionFilters.

Source

pub async fn get_files_by_partitions( &self, filters: &[PartitionFilter], ) -> Result<Vec<Path>, DeltaTableError>

Returns the file list tracked in current table state filtered by provided PartitionFilters.

Source

pub async fn get_file_uris_by_partitions( &self, filters: &[PartitionFilter], ) -> Result<Vec<String>, DeltaTableError>

Return the file uris as strings for the partition(s)

Source

pub fn get_file_uris( &self, ) -> Result<impl Iterator<Item = String>, DeltaTableError>

Returns a URIs for all active files present in the current table version.

Source

pub fn snapshot(&self) -> Result<&DeltaTableState, DeltaTableError>

Returns the currently loaded state snapshot.

This method provides access to the currently loaded state of the Delta table.

§Returns

A reference to the current state of the Delta table.

§Errors

Returns NotInitialized if the table has not been initialized.

Source

pub async fn load_with_datetime( &mut self, datetime: DateTime<Utc>, ) -> Result<(), DeltaTableError>

Time travel Delta table to the latest version that’s created at or before provided datetime argument.

Internally, this methods performs a binary search on all Delta transaction logs.

Source§

impl DeltaTable

Source

pub fn table_provider(&self) -> TableProviderBuilder

Get a table provider for the table referenced by this DeltaTable.

See TableProviderBuilder for options when building the provider.

Source

pub fn update_datafusion_session( &self, session: &dyn Session, ) -> Result<(), DeltaTableError>

Ensure the provided DataFusion session is prepared to read this table.

This registers the table’s root object store with the session’s RuntimeEnv if missing. Registration is idempotent and will not overwrite an existing mapping.

If the session already has an object store registered for the table’s URL but it is stale or incorrect, this method will not replace it. To override an existing mapping, call RuntimeEnv::register_object_store directly.

use datafusion::prelude::SessionContext;
use deltalake_core::{DeltaResult, DeltaTable};

let table = DeltaTable::new_in_memory();
let ctx = SessionContext::new();
let state = ctx.state();
table.update_datafusion_session(&state)?;

Trait Implementations§

Source§

impl AsRef<DeltaTable> for DeltaOps

Source§

fn as_ref(&self) -> &DeltaTable

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for DeltaTable

Source§

fn clone(&self) -> DeltaTable

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 DeltaTable

Source§

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

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

impl<'de> Deserialize<'de> for DeltaTable

Source§

fn deserialize<D>( deserializer: D, ) -> Result<DeltaTable, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

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

impl Display for DeltaTable

Source§

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

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

impl From<DeltaOps> for DeltaTable

Source§

fn from(ops: DeltaOps) -> DeltaTable

Converts to this type from the input type.
Source§

impl From<DeltaTable> for DeltaOps

Source§

fn from(table: DeltaTable) -> DeltaOps

Converts to this type from the input type.
Source§

impl Serialize for DeltaTable

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

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> AsAny for T
where T: Any + Send + Sync,

Source§

fn any_ref(&self) -> &(dyn Any + Send + Sync + 'static)

Obtains a dyn Any reference to the object: Read more
Source§

fn as_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Obtains an Arc<dyn Any> reference to the object: Read more
Source§

fn into_any(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts the object to Box<dyn Any>: Read more
Source§

fn type_name(&self) -> &'static str

Convenient wrapper for std::any::type_name, since Any does not provide it and Any::type_id is useless as a debugging aid (its Debug is just a mess of hex digits).
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> 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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelType
where ArrowType: TryFromKernel<KernelType>,

Source§

fn try_into_arrow(self) -> Result<ArrowType, ArrowError>

Source§

impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowType
where KernelType: TryFromArrow<ArrowType>,

Source§

fn try_into_kernel(self) -> Result<KernelType, ArrowError>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ValidateIp for T
where T: ToString,

Source§

fn validate_ipv4(&self) -> bool

Validates whether the given string is an IP V4
Source§

fn validate_ipv6(&self) -> bool

Validates whether the given string is an IP V6
Source§

fn validate_ip(&self) -> bool

Validates whether the given string is an IP
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>,

Source§

impl<T> Ungil for T
where T: Send,