Skip to content

Commit

Permalink
fix the test_restore_by_datetime test
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Ulmasov <[email protected]>
  • Loading branch information
r3stl355 authored and rtyler committed Jan 1, 2024
1 parent 74f9d33 commit 40e3b0d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/deltalake-core/tests/command_restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use arrow_schema::{DataType as ArrowDataType, Field};
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use deltalake_core::kernel::{DataType, PrimitiveType, StructField};
use deltalake_core::protocol::SaveMode;
use deltalake_core::storage::commit_uri_from_version;
use deltalake_core::{DeltaOps, DeltaTable};
use rand::Rng;
use std::error::Error;
Expand Down Expand Up @@ -117,9 +118,15 @@ async fn test_restore_by_version() -> Result<(), Box<dyn Error>> {
#[tokio::test]
async fn test_restore_by_datetime() -> Result<(), Box<dyn Error>> {
let context = setup_test().await?;
let mut table = context.table;
let history = table.history(Some(10)).await?;
let timestamp = history.get(1).unwrap().timestamp.unwrap();
let table = context.table;
let version = 1;

// The way we obtain a timestamp for a version will have to change when/if we start using CommitInfo for timestamps
let meta = table
.object_store()
.head(&commit_uri_from_version(version))
.await?;
let timestamp = meta.last_modified.timestamp_millis();
let naive = NaiveDateTime::from_timestamp_millis(timestamp).unwrap();
let datetime: DateTime<Utc> = Utc.from_utc_datetime(&naive);

Expand Down

0 comments on commit 40e3b0d

Please sign in to comment.