Skip to content

Commit

Permalink
extend test for roundtripping metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-elgreco committed Jan 1, 2024
1 parent 81ae502 commit d8619e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 9 additions & 1 deletion crates/deltalake-core/src/operations/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions crates/deltalake-core/src/operations/merge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
10 changes: 9 additions & 1 deletion crates/deltalake-core/src/operations/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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 |",
Expand Down

0 comments on commit d8619e4

Please sign in to comment.