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: DeltaTableConfigthe load options used during load
Implementations§
Source§impl DeltaTable
impl DeltaTable
Sourcepub async fn try_from_url(uri: Url) -> Result<DeltaTable, DeltaTableError>
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();
};Sourcepub async fn try_from_url_with_storage_options(
uri: Url,
storage_options: HashMap<String, String>,
) -> Result<DeltaTable, DeltaTableError>
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
pub fn create(&self) -> CreateBuilder
pub fn restore(self) -> RestoreBuilder
Sourcepub fn vacuum(self) -> VacuumBuilder
pub fn vacuum(self) -> VacuumBuilder
Vacuum stale files from delta table
Sourcepub fn filesystem_check(self) -> FileSystemCheckBuilder
pub fn filesystem_check(self) -> FileSystemCheckBuilder
Audit active files with files present on the filesystem
Sourcepub fn add_feature(self) -> AddTableFeatureBuilder
pub fn add_feature(self) -> AddTableFeatureBuilder
Enable a table feature for a table
Sourcepub fn set_tbl_properties(self) -> SetTablePropertiesBuilder
pub fn set_tbl_properties(self) -> SetTablePropertiesBuilder
Set table properties
Sourcepub fn add_columns(self) -> AddColumnBuilder
pub fn add_columns(self) -> AddColumnBuilder
Add new columns
Sourcepub fn update_field_metadata(self) -> UpdateFieldMetadataBuilder
pub fn update_field_metadata(self) -> UpdateFieldMetadataBuilder
Update field metadata
Sourcepub fn update_table_metadata(self) -> UpdateTableMetadataBuilder
pub fn update_table_metadata(self) -> UpdateTableMetadataBuilder
Update table metadata
Sourcepub fn generate(self) -> GenerateBuilder
pub fn generate(self) -> GenerateBuilder
Generate a symlink_format_manifest for other engines
Source§impl DeltaTable
impl DeltaTable
pub fn scan_table(&self) -> LoadBuilder
Sourcepub fn scan_cdf(self) -> CdfLoadBuilder
pub fn scan_cdf(self) -> CdfLoadBuilder
Load a table with CDF Enabled
pub fn write( self, batches: impl IntoIterator<Item = RecordBatch>, ) -> WriteBuilder
Sourcepub fn optimize<'a>(self) -> OptimizeBuilder<'a>
pub fn optimize<'a>(self) -> OptimizeBuilder<'a>
Audit active files with files present on the filesystem
Sourcepub fn delete(self) -> DeleteBuilder
pub fn delete(self) -> DeleteBuilder
Delete data from Delta table
Sourcepub fn update(self) -> UpdateBuilder
pub fn update(self) -> UpdateBuilder
Update data from Delta table
Sourcepub fn merge<E>(self, source: DataFrame, predicate: E) -> MergeBuilderwhere
E: Into<Expression>,
pub fn merge<E>(self, source: DataFrame, predicate: E) -> MergeBuilderwhere
E: Into<Expression>,
Update data from Delta table
Sourcepub fn add_constraint(self) -> ConstraintBuilder
pub fn add_constraint(self) -> ConstraintBuilder
Add a check constraint to a table
Sourcepub fn drop_constraints(self) -> DropConstraintBuilder
pub fn drop_constraints(self) -> DropConstraintBuilder
Drops constraints from a table
Source§impl DeltaTable
impl DeltaTable
Sourcepub fn new(log_store: Arc<dyn LogStore>, config: DeltaTableConfig) -> DeltaTable
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.
Sourcepub fn new_in_memory() -> DeltaTable
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();Sourcepub fn object_store(&self) -> Arc<dyn ObjectStore> ⓘ
pub fn object_store(&self) -> Arc<dyn ObjectStore> ⓘ
get a shared reference to the delta object store
Sourcepub async fn verify_deltatable_existence(&self) -> Result<bool, DeltaTableError>
pub async fn verify_deltatable_existence(&self) -> Result<bool, DeltaTableError>
Check if the DeltaTable exists
Sourcepub async fn get_latest_version(&self) -> Result<u64, DeltaTableError>
pub async fn get_latest_version(&self) -> Result<u64, DeltaTableError>
returns the latest available version of the table
Sourcepub fn version(&self) -> Option<u64>
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.
Sourcepub async fn load(&mut self) -> Result<(), DeltaTableError>
pub async fn load(&mut self) -> Result<(), DeltaTableError>
Load DeltaTable with data from latest checkpoint
Sourcepub async fn update_state(&mut self) -> Result<(), DeltaTableError>
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.
Sourcepub async fn update_incremental(
&mut self,
max_version: Option<u64>,
) -> Result<(), DeltaTableError>
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.
Sourcepub async fn load_version(
&mut self,
version: u64,
) -> Result<(), DeltaTableError>
pub async fn load_version( &mut self, version: u64, ) -> Result<(), DeltaTableError>
Loads the DeltaTable state for the given version.
Sourcepub async fn history(
&self,
limit: Option<usize>,
) -> Result<impl Iterator<Item = CommitInfo> + use<>, DeltaTableError>
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.
Sourcepub fn get_active_add_actions_by_partitions(
&self,
filters: &[PartitionFilter],
) -> Pin<Box<dyn Stream<Item = Result<LogicalFileView, DeltaTableError>> + Send + '_>>
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.
Sourcepub async fn get_files_by_partitions(
&self,
filters: &[PartitionFilter],
) -> Result<Vec<Path>, DeltaTableError>
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.
Sourcepub async fn get_file_uris_by_partitions(
&self,
filters: &[PartitionFilter],
) -> Result<Vec<String>, DeltaTableError>
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)
Sourcepub fn get_file_uris(
&self,
) -> Result<impl Iterator<Item = String>, DeltaTableError>
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.
Sourcepub fn snapshot(&self) -> Result<&DeltaTableState, DeltaTableError>
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.
Sourcepub async fn load_with_datetime(
&mut self,
datetime: DateTime<Utc>,
) -> Result<(), DeltaTableError>
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
impl DeltaTable
Sourcepub fn table_provider(&self) -> TableProviderBuilder
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.
Sourcepub fn update_datafusion_session(
&self,
session: &dyn Session,
) -> Result<(), DeltaTableError>
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
impl AsRef<DeltaTable> for DeltaOps
Source§fn as_ref(&self) -> &DeltaTable
fn as_ref(&self) -> &DeltaTable
Source§impl Clone for DeltaTable
impl Clone for DeltaTable
Source§fn clone(&self) -> DeltaTable
fn clone(&self) -> DeltaTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DeltaTable
impl Debug for DeltaTable
Source§impl<'de> Deserialize<'de> for DeltaTable
impl<'de> Deserialize<'de> for DeltaTable
Source§fn deserialize<D>(
deserializer: D,
) -> Result<DeltaTable, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<DeltaTable, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for DeltaTable
impl Display for DeltaTable
Source§impl From<DeltaOps> for DeltaTable
impl From<DeltaOps> for DeltaTable
Source§fn from(ops: DeltaOps) -> DeltaTable
fn from(ops: DeltaOps) -> DeltaTable
Source§impl From<DeltaTable> for DeltaOps
impl From<DeltaTable> for DeltaOps
Source§fn from(table: DeltaTable) -> DeltaOps
fn from(table: DeltaTable) -> DeltaOps
Source§impl Serialize for DeltaTable
impl Serialize for DeltaTable
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl Freeze for DeltaTable
impl !RefUnwindSafe for DeltaTable
impl Send for DeltaTable
impl Sync for DeltaTable
impl Unpin for DeltaTable
impl UnsafeUnpin for DeltaTable
impl !UnwindSafe for DeltaTable
Blanket Implementations§
Source§impl<T> AsAny for T
impl<T> AsAny for T
Source§fn any_ref(&self) -> &(dyn Any + Send + Sync + 'static)
fn any_ref(&self) -> &(dyn Any + Send + Sync + 'static)
dyn Any reference to the object: Read moreSource§fn as_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ
fn as_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ
Arc<dyn Any> reference to the object: Read moreSource§fn into_any(self: Box<T>) -> Box<dyn Any + Send + Sync>
fn into_any(self: Box<T>) -> Box<dyn Any + Send + Sync>
Box<dyn Any>: Read moreSource§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.