Skip to content

Commit e4b2f21

Browse files
authored
Merge branch 'main' into delta-table-row-count-function
2 parents caa6da3 + d148c32 commit e4b2f21

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

crates/core/src/kernel/schema/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::any::Any;
44
use std::sync::Arc;
55

66
pub use delta_kernel::schema::{
7-
ArrayType, ColumnMetadataKey, DataType, MapType, MetadataValue, PrimitiveType, StructField,
8-
StructType,
7+
ArrayType, ColumnMetadataKey, DataType, DecimalType, MapType, MetadataValue, PrimitiveType,
8+
StructField, StructType,
99
};
1010
use serde_json::Value;
1111

crates/core/src/operations/merge/barrier.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
//! they can be removed from the delta log.
1111
1212
use std::{
13-
collections::{HashMap, HashSet},
13+
collections::HashMap,
1414
pin::Pin,
15-
sync::{Arc, Mutex},
15+
sync::Arc,
1616
task::{Context, Poll},
1717
};
1818

19-
use arrow_array::{builder::UInt64Builder, ArrayRef, RecordBatch};
20-
use arrow_schema::SchemaRef;
19+
use arrow::array::{builder::UInt64Builder, ArrayRef, RecordBatch};
20+
use arrow::datatypes::SchemaRef;
21+
use dashmap::DashSet;
2122
use datafusion::common::{DataFusionError, Result as DataFusionResult};
2223
use datafusion::logical_expr::{Expr, LogicalPlan, UserDefinedLogicalNodeCore};
2324
use datafusion::physical_expr::{Distribution, PhysicalExpr};
@@ -32,7 +33,7 @@ use crate::{
3233
DeltaTableError,
3334
};
3435

35-
pub(crate) type BarrierSurvivorSet = Arc<Mutex<HashSet<String>>>;
36+
pub(crate) type BarrierSurvivorSet = Arc<DashSet<String>>;
3637

3738
#[derive(Debug)]
3839
/// Physical Node for the MergeBarrier
@@ -55,7 +56,7 @@ impl MergeBarrierExec {
5556
MergeBarrierExec {
5657
input,
5758
file_column,
58-
survivors: Arc::new(Mutex::new(HashSet::new())),
59+
survivors: Arc::new(DashSet::new()),
5960
expr,
6061
}
6162
}
@@ -359,17 +360,12 @@ impl Stream for MergeBarrierStream {
359360
}
360361

361362
{
362-
let mut lock = self.survivors.lock().map_err(|_| {
363-
DataFusionError::External(Box::new(DeltaTableError::Generic(
364-
"MergeBarrier mutex is poisoned".to_string(),
365-
)))
366-
})?;
367363
for part in &self.file_partitions {
368364
match part.state {
369365
PartitionBarrierState::Closed => {}
370366
PartitionBarrierState::Open => {
371367
if let Some(file_name) = &part.file_name {
372-
lock.insert(file_name.to_owned());
368+
self.survivors.insert(file_name.to_owned());
373369
}
374370
}
375371
}
@@ -532,11 +528,10 @@ mod tests {
532528
];
533529
assert_batches_sorted_eq!(&expected, &actual);
534530

535-
let s = survivors.lock().unwrap();
536-
assert!(!s.contains(&"file0".to_string()));
537-
assert!(s.contains(&"file1".to_string()));
538-
assert!(s.contains(&"file2".to_string()));
539-
assert_eq!(s.len(), 2);
531+
assert!(!survivors.contains(&"file0".to_string()));
532+
assert!(survivors.contains(&"file1".to_string()));
533+
assert!(survivors.contains(&"file2".to_string()));
534+
assert_eq!(survivors.len(), 2);
540535
}
541536

542537
#[tokio::test]

crates/core/src/operations/merge/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,9 +1413,8 @@ async fn execute(
14131413
.survivors();
14141414

14151415
{
1416-
let lock = survivors.lock().unwrap();
14171416
for action in snapshot.log_data() {
1418-
if lock.contains(action.path().as_ref()) {
1417+
if survivors.contains(action.path().as_ref()) {
14191418
metrics.num_target_files_removed += 1;
14201419
actions.push(action.remove_action(true).into());
14211420
}

0 commit comments

Comments
 (0)