Skip to main content

latest_version_as_of

Function latest_version_as_of 

Source
pub fn latest_version_as_of(
    snapshot: &Snapshot,
    engine: &dyn Engine,
    timestamp: Timestamp,
    resolved_commit_type: HistoryCommitType,
) -> DeltaResult<CommitAt>
Expand description

Gets the latest CommitAt (version and timestamp) with a timestamp at or before timestamp.

resolved_commit_type constrains the returned version:

§Errors

Returns LogHistoryError::TimestampOutOfRange if no version exists at or before the given timestamp.

§Examples

ⓘ
use delta_kernel::snapshot::Snapshot;
use test_utils::delta_kernel_default_engine::DefaultEngine;
use delta_kernel::history_manager::{latest_version_as_of, HistoryCommitType};

let engine = DefaultEngine::try_new(...)?;
let snapshot = Snapshot::builder_for(table_uri).build(&engine)?;

// Get the latest commit as of January 1, 2023
let timestamp = 1672531200000; // Milliseconds since epoch for 2023-01-01
let commit = latest_version_as_of(&snapshot, &engine, timestamp, HistoryCommitType::Recreatable)?;