Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl TableProvider for CustomDataSource {
struct CustomExec {
db: CustomDataSource,
projected_schema: SchemaRef,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl CustomExec {
Expand All @@ -207,7 +207,7 @@ impl CustomExec {
Self {
db,
projected_schema,
cache,
cache: Arc::new(cache),
}
}

Expand Down Expand Up @@ -238,7 +238,7 @@ impl ExecutionPlan for CustomExec {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl ExternalBatchBufferer {
struct BufferingExecutionPlan {
schema: SchemaRef,
input: Arc<dyn ExecutionPlan>,
properties: PlanProperties,
properties: Arc<PlanProperties>,
}

impl BufferingExecutionPlan {
Expand Down Expand Up @@ -233,7 +233,7 @@ impl ExecutionPlan for BufferingExecutionPlan {
self.schema.clone()
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.properties
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl ExecutionPlan for ParentExec {
self
}

fn properties(&self) -> &datafusion::physical_plan::PlanProperties {
fn properties(&self) -> &Arc<datafusion::physical_plan::PlanProperties> {
unreachable!()
}

Expand Down Expand Up @@ -182,7 +182,7 @@ impl ExecutionPlan for ChildExec {
self
}

fn properties(&self) -> &datafusion::physical_plan::PlanProperties {
fn properties(&self) -> &Arc<datafusion::physical_plan::PlanProperties> {
unreachable!()
}

Expand Down
6 changes: 3 additions & 3 deletions datafusion-examples/examples/relation_planner/table_sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ pub struct SampleExec {
upper_bound: f64,
seed: u64,
metrics: ExecutionPlanMetricsSet,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl SampleExec {
Expand Down Expand Up @@ -656,7 +656,7 @@ impl SampleExec {
upper_bound,
seed,
metrics: ExecutionPlanMetricsSet::new(),
cache,
cache: Arc::new(cache),
})
}

Expand Down Expand Up @@ -686,7 +686,7 @@ impl ExecutionPlan for SampleExec {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
6 changes: 3 additions & 3 deletions datafusion/catalog/src/memory/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ fn evaluate_filters_to_mask(
struct DmlResultExec {
rows_affected: u64,
schema: SchemaRef,
properties: PlanProperties,
properties: Arc<PlanProperties>,
}

impl DmlResultExec {
Expand All @@ -570,7 +570,7 @@ impl DmlResultExec {
Self {
rows_affected,
schema,
properties,
properties: Arc::new(properties),
}
}
}
Expand Down Expand Up @@ -604,7 +604,7 @@ impl ExecutionPlan for DmlResultExec {
Arc::clone(&self.schema)
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.properties
}

Expand Down
2 changes: 2 additions & 0 deletions datafusion/core/benches/reset_plan_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ fn run_reset_states(b: &mut criterion::Bencher, plan: &Arc<dyn ExecutionPlan>) {
/// making an independent instance of the execution plan to re-execute it, avoiding
/// re-planning stage.
fn bench_reset_plan_states(c: &mut Criterion) {
env_logger::init();

let rt = Runtime::new().unwrap();
let ctx = SessionContext::new();
ctx.register_table(
Expand Down
14 changes: 8 additions & 6 deletions datafusion/core/src/physical_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3661,13 +3661,15 @@ mod tests {

#[derive(Debug)]
struct NoOpExecutionPlan {
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl NoOpExecutionPlan {
fn new(schema: SchemaRef) -> Self {
let cache = Self::compute_properties(schema);
Self { cache }
Self {
cache: Arc::new(cache),
}
}

/// This function creates the cache object that stores the plan properties such as schema, equivalence properties, ordering, partitioning, etc.
Expand Down Expand Up @@ -3705,7 +3707,7 @@ mod tests {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down Expand Up @@ -3859,7 +3861,7 @@ digraph {
fn children(&self) -> Vec<&Arc<dyn ExecutionPlan>> {
self.0.iter().collect::<Vec<_>>()
}
fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
unimplemented!()
}
fn execute(
Expand Down Expand Up @@ -3908,7 +3910,7 @@ digraph {
fn children(&self) -> Vec<&Arc<dyn ExecutionPlan>> {
unimplemented!()
}
fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
unimplemented!()
}
fn execute(
Expand Down Expand Up @@ -4029,7 +4031,7 @@ digraph {
fn children(&self) -> Vec<&Arc<dyn ExecutionPlan>> {
vec![]
}
fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
unimplemented!()
}
fn execute(
Expand Down
9 changes: 6 additions & 3 deletions datafusion/core/tests/custom_sources_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct CustomTableProvider;
#[derive(Debug, Clone)]
struct CustomExecutionPlan {
projection: Option<Vec<usize>>,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl CustomExecutionPlan {
Expand All @@ -88,7 +88,10 @@ impl CustomExecutionPlan {
let schema =
project_schema(&schema, projection.as_ref()).expect("projected schema");
let cache = Self::compute_properties(schema);
Self { projection, cache }
Self {
projection,
cache: Arc::new(cache),
}
}

/// This function creates the cache object that stores the plan properties such as schema, equivalence properties, ordering, partitioning, etc.
Expand Down Expand Up @@ -157,7 +160,7 @@ impl ExecutionPlan for CustomExecutionPlan {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ fn create_batch(value: i32, num_rows: usize) -> Result<RecordBatch> {
#[derive(Debug)]
struct CustomPlan {
batches: Vec<RecordBatch>,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl CustomPlan {
fn new(schema: SchemaRef, batches: Vec<RecordBatch>) -> Self {
let cache = Self::compute_properties(schema);
Self { batches, cache }
Self {
batches,
cache: Arc::new(cache),
}
}

/// This function creates the cache object that stores the plan properties such as schema, equivalence properties, ordering, partitioning, etc.
Expand Down Expand Up @@ -109,7 +112,7 @@ impl ExecutionPlan for CustomPlan {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
6 changes: 3 additions & 3 deletions datafusion/core/tests/custom_sources_cases/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use async_trait::async_trait;
struct StatisticsValidation {
stats: Statistics,
schema: Arc<Schema>,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl StatisticsValidation {
Expand All @@ -59,7 +59,7 @@ impl StatisticsValidation {
Self {
stats,
schema,
cache,
cache: Arc::new(cache),
}
}

Expand Down Expand Up @@ -158,7 +158,7 @@ impl ExecutionPlan for StatisticsValidation {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
6 changes: 3 additions & 3 deletions datafusion/core/tests/fuzz_cases/once_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::sync::{Arc, Mutex};
pub struct OnceExec {
/// the results to send back
stream: Mutex<Option<SendableRecordBatchStream>>,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl Debug for OnceExec {
Expand All @@ -46,7 +46,7 @@ impl OnceExec {
let cache = Self::compute_properties(stream.schema());
Self {
stream: Mutex::new(Some(stream)),
cache,
cache: Arc::new(cache),
}
}

Expand Down Expand Up @@ -83,7 +83,7 @@ impl ExecutionPlan for OnceExec {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ macro_rules! assert_plan {
struct SortRequiredExec {
input: Arc<dyn ExecutionPlan>,
expr: LexOrdering,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl SortRequiredExec {
Expand All @@ -132,7 +132,7 @@ impl SortRequiredExec {
Self {
input,
expr: requirement,
cache,
cache: Arc::new(cache),
}
}

Expand Down Expand Up @@ -174,7 +174,7 @@ impl ExecutionPlan for SortRequiredExec {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl ExecutionPlan for TestNode {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
self.input.properties()
}

Expand Down
17 changes: 10 additions & 7 deletions datafusion/core/tests/physical_optimizer/join_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,10 @@ async fn test_hash_join_swap_on_joins_with_projections(
"ProjectionExec won't be added above if HashJoinExec contains embedded projection",
);

assert_eq!(swapped_join.projection, Some(vec![0_usize]));
assert_eq!(
swapped_join.projection.as_ref().map(|p| p.to_vec()),
Some(vec![0_usize])
);
assert_eq!(swapped.schema().fields.len(), 1);
assert_eq!(swapped.schema().fields[0].name(), "small_col");
Ok(())
Expand Down Expand Up @@ -979,7 +982,7 @@ impl RecordBatchStream for UnboundedStream {
pub struct UnboundedExec {
batch_produce: Option<usize>,
batch: RecordBatch,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl UnboundedExec {
Expand All @@ -995,7 +998,7 @@ impl UnboundedExec {
Self {
batch_produce,
batch,
cache,
cache: Arc::new(cache),
}
}

Expand Down Expand Up @@ -1052,7 +1055,7 @@ impl ExecutionPlan for UnboundedExec {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down Expand Up @@ -1091,7 +1094,7 @@ pub enum SourceType {
pub struct StatisticsExec {
stats: Statistics,
schema: Arc<Schema>,
cache: PlanProperties,
cache: Arc<PlanProperties>,
}

impl StatisticsExec {
Expand All @@ -1105,7 +1108,7 @@ impl StatisticsExec {
Self {
stats,
schema: Arc::new(schema),
cache,
cache: Arc::new(cache),
}
}

Expand Down Expand Up @@ -1153,7 +1156,7 @@ impl ExecutionPlan for StatisticsExec {
self
}

fn properties(&self) -> &PlanProperties {
fn properties(&self) -> &Arc<PlanProperties> {
&self.cache
}

Expand Down
Loading