From d8619e40184b26c88f0f34f227678d57a36f7273 Mon Sep 17 00:00:00 2001 From: ion-elgreco <15728914+ion-elgreco@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:26:29 +0100 Subject: [PATCH] extend test for roundtripping metrics --- crates/deltalake-core/src/operations/delete.rs | 10 +++++++++- crates/deltalake-core/src/operations/merge/mod.rs | 5 +++++ crates/deltalake-core/src/operations/update.rs | 10 +++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/deltalake-core/src/operations/delete.rs b/crates/deltalake-core/src/operations/delete.rs index 37d5a99183..7649760d2a 100644 --- a/crates/deltalake-core/src/operations/delete.rs +++ b/crates/deltalake-core/src/operations/delete.rs @@ -403,7 +403,7 @@ mod tests { assert_eq!(table.version(), 1); assert_eq!(table.get_file_uris().count(), 1); - let (table, metrics) = DeltaOps(table).delete().await.unwrap(); + let (mut table, metrics) = DeltaOps(table).delete().await.unwrap(); assert_eq!(table.version(), 2); assert_eq!(table.get_file_uris().count(), 0); @@ -412,6 +412,14 @@ mod tests { assert_eq!(metrics.num_deleted_rows, None); assert_eq!(metrics.num_copied_rows, None); + let commit_info = table.history(None).await.unwrap(); + let last_commit = &commit_info[commit_info.len() - 1]; + let extra_info = last_commit.info.clone(); + assert_eq!( + extra_info["operationMetrics"], + serde_json::to_value(metrics.clone()).unwrap() + ); + // rewrite is not required assert_eq!(metrics.rewrite_time_ms, 0); diff --git a/crates/deltalake-core/src/operations/merge/mod.rs b/crates/deltalake-core/src/operations/merge/mod.rs index d1e4f00239..6e42d690d7 100644 --- a/crates/deltalake-core/src/operations/merge/mod.rs +++ b/crates/deltalake-core/src/operations/merge/mod.rs @@ -2066,6 +2066,11 @@ mod tests { let commit_info = table.history(None).await.unwrap(); let last_commit = &commit_info[commit_info.len() - 1]; let parameters = last_commit.operation_parameters.clone().unwrap(); + let extra_info = last_commit.info.clone(); + assert_eq!( + extra_info["operationMetrics"], + serde_json::to_value(metrics.clone()).unwrap() + ); assert_eq!(parameters["predicate"], json!("target.id = source.id")); assert_eq!( parameters["matchedPredicates"], diff --git a/crates/deltalake-core/src/operations/update.rs b/crates/deltalake-core/src/operations/update.rs index 1fad08e820..57aaed97ed 100644 --- a/crates/deltalake-core/src/operations/update.rs +++ b/crates/deltalake-core/src/operations/update.rs @@ -858,7 +858,7 @@ mod tests { // Validate order operators do not include nulls let table = prepare_values_table().await; - let (table, metrics) = DeltaOps(table) + let (mut table, metrics) = DeltaOps(table) .update() .with_predicate(col("value").gt(lit(2)).or(col("value").lt(lit(2)))) .with_update("value", lit(10)) @@ -871,6 +871,14 @@ mod tests { assert_eq!(metrics.num_updated_rows, 2); assert_eq!(metrics.num_copied_rows, 3); + let commit_info = table.history(None).await.unwrap(); + let last_commit = &commit_info[commit_info.len() - 1]; + let extra_info = last_commit.info.clone(); + assert_eq!( + extra_info["operationMetrics"], + serde_json::to_value(metrics.clone()).unwrap() + ); + let expected = [ "+-------+", "| value |",