From 40e3b0d52d4fd84502d8afa8130d6dd8f510d421 Mon Sep 17 00:00:00 2001 From: Nikolay Ulmasov Date: Mon, 1 Jan 2024 18:04:30 +0000 Subject: [PATCH] fix the test_restore_by_datetime test Signed-off-by: Nikolay Ulmasov --- crates/deltalake-core/tests/command_restore.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/deltalake-core/tests/command_restore.rs b/crates/deltalake-core/tests/command_restore.rs index 2c1c06cbb6..fd8d77c8b9 100644 --- a/crates/deltalake-core/tests/command_restore.rs +++ b/crates/deltalake-core/tests/command_restore.rs @@ -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; @@ -117,9 +118,15 @@ async fn test_restore_by_version() -> Result<(), Box> { #[tokio::test] async fn test_restore_by_datetime() -> Result<(), Box> { 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.from_utc_datetime(&naive);