Skip to content
Merged
Show file tree
Hide file tree
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
430 changes: 188 additions & 242 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ edition = "2024"
rust-version = "1.88.0"

[workspace.dependencies]
arrow = { version = "58", features = ["ipc_compression"] }
arrow-flight = { version = "58", features = ["flight-sql-experimental"] }
arrow = { version = "58.3", features = ["ipc_compression"] }
arrow-flight = { version = "58.3", features = ["flight-sql-experimental"] }
clap = { version = "4.5", features = ["derive", "cargo"] }

datafusion = "53"
datafusion-cli = "53"
datafusion-proto = "53"
datafusion-proto-common = "53"
datafusion-spark = "53"
datafusion-substrait = "53"
datafusion = "54"
datafusion-cli = "54"
datafusion-proto = "54"
datafusion-proto-common = "54"
datafusion-spark = "54"
datafusion-substrait = "54"

insta = "1.47"
itertools = "0.15"
object_store = "0.13"
object_store = "0.13.2"
prost = "0.14"
prost-types = "0.14"
rstest = { version = "0.26" }
Expand Down
2 changes: 1 addition & 1 deletion ballista-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ crate-type = ["cdylib", "rlib"]
ballista = { path = "../ballista/client", version = "53.0.0", features = ["standalone"], optional = true }
datafusion = { workspace = true, optional = true }
datafusion-cli = { workspace = true, optional = true }
rustyline = { version = "17.0.1", optional = true }
rustyline = { version = "18.0.0", optional = true }
mimalloc = { workspace = true, optional = true }

# TUI/web shared deps
Expand Down
2 changes: 1 addition & 1 deletion ballista/client/tests/context_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ mod basic {
"+-------------------------------------------------------------------+",
"| approx_percentile_cont_with_weight(test.id,Int64(2),Float64(0.5)) |",
"+-------------------------------------------------------------------+",
"| 3 |",
"| 3.5 |",
"+-------------------------------------------------------------------+",
];
assert_result_eq(expected, &res);
Expand Down
40 changes: 12 additions & 28 deletions ballista/core/src/diagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,43 +84,27 @@ fn build_exec_plan_diagram(
id: &mut AtomicUsize,
draw_entity: bool,
) -> Result<usize> {
let operator_str = if plan.as_any().downcast_ref::<AggregateExec>().is_some() {
let operator_str = if plan.downcast_ref::<AggregateExec>().is_some() {
"AggregateExec"
} else if plan.as_any().downcast_ref::<SortExec>().is_some() {
} else if plan.downcast_ref::<SortExec>().is_some() {
"SortExec"
} else if plan.as_any().downcast_ref::<ProjectionExec>().is_some() {
} else if plan.downcast_ref::<ProjectionExec>().is_some() {
"ProjectionExec"
} else if plan.as_any().downcast_ref::<HashJoinExec>().is_some() {
} else if plan.downcast_ref::<HashJoinExec>().is_some() {
"HashJoinExec"
} else if plan.as_any().downcast_ref::<DataSourceExec>().is_some() {
} else if plan.downcast_ref::<DataSourceExec>().is_some() {
"DataSourceExec"
} else if plan.as_any().downcast_ref::<FilterExec>().is_some() {
} else if plan.downcast_ref::<FilterExec>().is_some() {
"FilterExec"
} else if plan.as_any().downcast_ref::<ShuffleWriterExec>().is_some() {
} else if plan.downcast_ref::<ShuffleWriterExec>().is_some() {
"ShuffleWriterExec"
} else if plan
.as_any()
.downcast_ref::<SortShuffleWriterExec>()
.is_some()
{
} else if plan.downcast_ref::<SortShuffleWriterExec>().is_some() {
"SortShuffleWriterExec"
} else if plan
.as_any()
.downcast_ref::<UnresolvedShuffleExec>()
.is_some()
{
} else if plan.downcast_ref::<UnresolvedShuffleExec>().is_some() {
"UnresolvedShuffleExec"
} else if plan
.as_any()
.downcast_ref::<CoalesceBatchesExec>()
.is_some()
{
} else if plan.downcast_ref::<CoalesceBatchesExec>().is_some() {
"CoalesceBatchesExec"
} else if plan
.as_any()
.downcast_ref::<CoalescePartitionsExec>()
.is_some()
{
} else if plan.downcast_ref::<CoalescePartitionsExec>().is_some() {
"CoalescePartitionsExec"
} else {
warn!("Unknown: {plan:?}");
Expand All @@ -137,7 +121,7 @@ fn build_exec_plan_diagram(
)?;
}
for child in plan.children() {
if let Some(shuffle) = child.as_any().downcast_ref::<UnresolvedShuffleExec>() {
if let Some(shuffle) = child.downcast_ref::<UnresolvedShuffleExec>() {
if !draw_entity {
writeln!(
w,
Expand Down
7 changes: 1 addition & 6 deletions ballista/core/src/execution_plans/chaos_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use datafusion::physical_plan::{
use futures::StreamExt;
use rand::rngs::StdRng;
use rand::{RngExt, SeedableRng};
use std::any::Any;
use std::sync::Arc;

/// Physical execution plan node that randomly injects failures for chaos/robustness testing.
Expand Down Expand Up @@ -124,10 +123,6 @@ impl ExecutionPlan for ChaosExec {
"ChaosExec"
}

fn as_any(&self) -> &dyn Any {
self
}

fn properties(&self) -> &Arc<PlanProperties> {
self.input.properties()
}
Expand Down Expand Up @@ -218,7 +213,7 @@ impl ExecutionPlan for ChaosExec {
self.input.metrics()
}

fn partition_statistics(&self, partition: Option<usize>) -> Result<Statistics> {
fn partition_statistics(&self, partition: Option<usize>) -> Result<Arc<Statistics>> {
self.input.partition_statistics(partition)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use datafusion::physical_plan::{
};
use datafusion_proto::logical_plan::AsLogicalPlan;
use futures::StreamExt;
use std::any::Any;
use std::convert::TryInto;
use std::marker::PhantomData;
use std::sync::Arc;
Expand Down Expand Up @@ -108,10 +107,6 @@ impl<T: 'static + AsLogicalPlan> ExecutionPlan for DistributedExplainAnalyzeExec
"DistributedExplainAnalyzeExec"
}

fn as_any(&self) -> &dyn Any {
self
}

fn properties(&self) -> &Arc<PlanProperties> {
&self.properties
}
Expand All @@ -133,7 +128,6 @@ impl<T: 'static + AsLogicalPlan> ExecutionPlan for DistributedExplainAnalyzeExec

let query_exec = children.pop().unwrap();
if query_exec
.as_any()
.downcast_ref::<DistributedQueryExec<T>>()
.is_some()
{
Expand Down Expand Up @@ -173,7 +167,6 @@ impl<T: 'static + AsLogicalPlan> ExecutionPlan for DistributedExplainAnalyzeExec
}

let job_id = query_exec
.as_any()
.downcast_ref::<DistributedQueryExec<T>>()
.ok_or_else(|| {
DataFusionError::Internal(
Expand Down
6 changes: 0 additions & 6 deletions ballista/core/src/execution_plans/distributed_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ use datafusion_proto::logical_plan::{
use futures::{Stream, StreamExt, TryFutureExt, TryStreamExt};
use log::{debug, error, info};
use parking_lot::Mutex;
use std::any::Any;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::sync::Arc;
Expand Down Expand Up @@ -177,10 +176,6 @@ impl<T: 'static + AsLogicalPlan> ExecutionPlan for DistributedQueryExec<T> {
"DistributedQueryExec"
}

fn as_any(&self) -> &dyn Any {
self
}

fn schema(&self) -> SchemaRef {
self.plan.schema().as_arrow().clone().into()
}
Expand Down Expand Up @@ -842,7 +837,6 @@ mod test {

let new_exec = exec.clone().with_new_children(vec![]).unwrap();
let new_exec = new_exec
.as_any()
.downcast_ref::<DistributedQueryExec<LogicalPlanNode>>()
.unwrap();

Expand Down
13 changes: 4 additions & 9 deletions ballista/core/src/execution_plans/shuffle_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use itertools::Itertools;
use log::{debug, error, trace};
use rand::prelude::SliceRandom;
use rand::rng;
use std::any::Any;
use std::collections::HashMap;
use std::fmt::Debug;
use std::fs::File;
Expand Down Expand Up @@ -311,10 +310,6 @@ impl ExecutionPlan for ShuffleReaderExec {
"ShuffleReaderExec"
}

fn as_any(&self) -> &dyn Any {
self
}

fn schema(&self) -> SchemaRef {
self.schema.clone()
}
Expand Down Expand Up @@ -426,7 +421,7 @@ impl ExecutionPlan for ShuffleReaderExec {
Some(self.metrics.clone_inner())
}

fn partition_statistics(&self, partition: Option<usize>) -> Result<Statistics> {
fn partition_statistics(&self, partition: Option<usize>) -> Result<Arc<Statistics>> {
if self.broadcast {
if let Some(idx) = partition
&& idx != 0
Expand All @@ -445,7 +440,7 @@ impl ExecutionPlan for ShuffleReaderExec {
"broadcast shuffle reader at stage {} returned aggregated statistics: {:?}",
self.stage_id, stats
);
return Ok(stats);
return Ok(Arc::new(stats));
}
if let Some(idx) = partition {
let partition_count = self.properties().partitioning.partition_count();
Expand Down Expand Up @@ -474,7 +469,7 @@ impl ExecutionPlan for ShuffleReaderExec {
"shuffle reader at stage: {} and partition {} returned statistics: {:?}",
self.stage_id, idx, stat_for_partition
);
stat_for_partition
stat_for_partition.map(Arc::new)
} else {
let stats_for_partitions = stats_for_partitions(
self.schema.fields().len(),
Expand All @@ -487,7 +482,7 @@ impl ExecutionPlan for ShuffleReaderExec {
"shuffle reader at stage: {} returned statistics for all partitions: {:?}",
self.stage_id, stats_for_partitions
);
Ok(stats_for_partitions)
Ok(Arc::new(stats_for_partitions))
}
}
}
Expand Down
47 changes: 22 additions & 25 deletions ballista/core/src/execution_plans/shuffle_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use datafusion::arrow::ipc::CompressionType;
use datafusion::arrow::ipc::writer::IpcWriteOptions;

use datafusion::arrow::ipc::writer::StreamWriter;
use std::any::Any;
use std::fmt::Debug;
use std::fs;
use std::fs::File;
Expand Down Expand Up @@ -286,7 +285,7 @@ impl ShuffleWriterExec {
exprs,
num_output_partitions,
repart_time,
);
)?;

while let Some(input_batch) = rx.blocking_recv() {
partitioner.partition(
Expand Down Expand Up @@ -438,10 +437,6 @@ impl ExecutionPlan for ShuffleWriterExec {
"ShuffleWriterExec"
}

fn as_any(&self) -> &dyn Any {
self
}

fn schema(&self) -> SchemaRef {
self.plan.schema()
}
Expand Down Expand Up @@ -561,7 +556,7 @@ impl ExecutionPlan for ShuffleWriterExec {
Some(self.metrics.clone_inner())
}

fn partition_statistics(&self, partition: Option<usize>) -> Result<Statistics> {
fn partition_statistics(&self, partition: Option<usize>) -> Result<Arc<Statistics>> {
self.plan.partition_statistics(partition)
}
}
Expand Down Expand Up @@ -635,23 +630,22 @@ mod tests {
assert_eq!(1, batches.len());
let batch = &batches[0];
assert_eq!(3, batch.num_columns());
assert_eq!(2, batch.num_rows());
// One metadata row per non-empty output partition; how many that is
// depends on the hash distribution, so only bound it.
let num_partitions = batch.num_rows();
assert!((1..=2).contains(&num_partitions));
let path = batch.columns()[1]
.as_any()
.downcast_ref::<StringArray>()
.unwrap();

let file0 = path.value(0);
assert!(
file0.ends_with("/jobOne/1/0/data-0.arrow")
|| file0.ends_with("\\jobOne\\1\\0\\data-0.arrow")
);
let file1 = path.value(1);

assert!(
file1.ends_with("/jobOne/1/1/data-0.arrow")
|| file1.ends_with("\\jobOne\\1\\1\\data-0.arrow")
);
for i in 0..num_partitions {
let f = path.value(i);
assert!(
(0..2).any(|p| f.ends_with(&format!("/jobOne/1/{p}/data-0.arrow"))
|| f.ends_with(&format!("\\jobOne\\1\\{p}\\data-0.arrow"))),
"unexpected shuffle file path: {f}"
);
}

let stats = batch.columns()[2]
.as_any()
Expand All @@ -664,8 +658,9 @@ mod tests {
.as_any()
.downcast_ref::<UInt64Array>()
.unwrap();
assert_eq!(4, num_rows.value(0));
assert_eq!(4, num_rows.value(1));
// Total rows are conserved across partitions regardless of the hash split.
let total: u64 = (0..num_partitions).map(|i| num_rows.value(i)).sum();
assert_eq!(8, total);

Ok(())
}
Expand Down Expand Up @@ -693,7 +688,8 @@ mod tests {
assert_eq!(1, batches.len());
let batch = &batches[0];
assert_eq!(3, batch.num_columns());
assert_eq!(2, batch.num_rows());
let num_partitions = batch.num_rows();
assert!((1..=2).contains(&num_partitions));
let stats = batch.columns()[2]
.as_any()
.downcast_ref::<StructArray>()
Expand All @@ -704,8 +700,9 @@ mod tests {
.as_any()
.downcast_ref::<UInt64Array>()
.unwrap();
assert_eq!(2, num_rows.value(0));
assert_eq!(2, num_rows.value(1));
// Total rows are conserved across partitions regardless of the hash split.
let total: u64 = (0..num_partitions).map(|i| num_rows.value(i)).sum();
assert_eq!(4, total);

Ok(())
}
Expand Down
Loading
Loading