Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the test_restore_by_datetime test #2010

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading