Skip to content

Apache DataFusion SQL Query Engine

ARROW-11489: [Rust][DataFusion] Make DataFrame be Send + Sync

Andrew Lamb0e565c0e266b
diff --git a/rust/datafusion/src/dataframe.rs b/rust/datafusion/src/dataframe.rs
index 04d827cc09..ca4ecc89df 100644
--- a/rust/datafusion/src/dataframe.rs
+++ b/rust/datafusion/src/dataframe.rs
@@ -51,7 +51,7 @@ use async_trait::async_trait;
/// # }
/// ```
#[async_trait]
-pub trait DataFrame {
+pub trait DataFrame: Send + Sync {
/// Filter the DataFrame by column. Returns a new DataFrame only containing the
/// specified columns.
///
diff --git a/rust/datafusion/src/execution/dataframe_impl.rs b/rust/datafusion/src/execution/dataframe_impl.rs
index 3a40d20a2a..5a4270efa6 100644
--- a/rust/datafusion/src/execution/dataframe_impl.rs
+++ b/rust/datafusion/src/execution/dataframe_impl.rs
@@ -315,6 +315,17 @@ mod tests {
Ok(())
}
+ #[tokio::test]
+ async fn sendable() {
+ let df = test_table().unwrap();
+ // dataframes should be sendable between threads/tasks
+ let task = tokio::task::spawn(async move {
+ df.select_columns(&["c1"])
+ .expect("should be usable in a task")
+ });
+ task.await.expect("task completed successfully");
+ }
+
/// Compare the formatted string representation of two plans for equality
fn assert_same_plan(plan1: &LogicalPlan, plan2: &LogicalPlan) {
assert_eq!(format!("{:?}", plan1), format!("{:?}", plan2));