Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name method to execution plan #9793

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions datafusion-examples/examples/custom_datasource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ impl DisplayAs for CustomExec {
}

impl ExecutionPlan for CustomExec {
fn name(&self) -> &'static str {
"CustomExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/core/src/datasource/physical_plan/arrow_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ impl DisplayAs for ArrowExec {
}

impl ExecutionPlan for ArrowExec {
fn name(&self) -> &'static str {
"ArrowExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/core/src/datasource/physical_plan/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ impl DisplayAs for AvroExec {
}

impl ExecutionPlan for AvroExec {
fn name(&self) -> &'static str {
"AvroExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/core/src/datasource/physical_plan/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ impl DisplayAs for CsvExec {
}

impl ExecutionPlan for CsvExec {
fn name(&self) -> &'static str {
"CsvExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/core/src/datasource/physical_plan/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ impl DisplayAs for NdJsonExec {
}

impl ExecutionPlan for NdJsonExec {
fn name(&self) -> &'static str {
"NdJsonExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/core/src/datasource/physical_plan/parquet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ impl DisplayAs for ParquetExec {
}

impl ExecutionPlan for ParquetExec {
fn name(&self) -> &'static str {
"ParquetExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,10 @@ pub(crate) mod tests {
}

impl ExecutionPlan for SortRequiredExec {
fn name(&self) -> &'static str {
"SortRequiredExec"
}

fn as_any(&self) -> &dyn std::any::Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/core/src/physical_optimizer/output_requirements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ impl DisplayAs for OutputRequirementExec {
}

impl ExecutionPlan for OutputRequirementExec {
fn name(&self) -> &'static str {
"OutputRequirementExec"
}

fn as_any(&self) -> &dyn std::any::Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/core/src/physical_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,10 @@ mod tests {
}

impl ExecutionPlan for NoOpExecutionPlan {
fn name(&self) -> &'static str {
"NoOpExecutionPlan"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
8 changes: 8 additions & 0 deletions datafusion/physical-plan/src/aggregates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ impl DisplayAs for AggregateExec {
}

impl ExecutionPlan for AggregateExec {
fn name(&self) -> &'static str {
"AggregateExec"
}

/// Return a reference to Any that can be used for down-casting
fn as_any(&self) -> &dyn Any {
self
Expand Down Expand Up @@ -1658,6 +1662,10 @@ mod tests {
}

impl ExecutionPlan for TestYieldingExec {
fn name(&self) -> &'static str {
"TestYieldingExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ impl DisplayAs for AnalyzeExec {
}

impl ExecutionPlan for AnalyzeExec {
fn name(&self) -> &'static str {
"AnalyzeExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/coalesce_batches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ impl DisplayAs for CoalesceBatchesExec {
}

impl ExecutionPlan for CoalesceBatchesExec {
fn name(&self) -> &'static str {
"CoalesceBatchesExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/coalesce_partitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ impl DisplayAs for CoalescePartitionsExec {
}

impl ExecutionPlan for CoalescePartitionsExec {
fn name(&self) -> &'static str {
"CoalescePartitionsExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ mod tests {
}

impl ExecutionPlan for TestStatsExecPlan {
fn name(&self) -> &'static str {
"TestStatsExecPlan"
}

fn as_any(&self) -> &dyn std::any::Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ impl DisplayAs for EmptyExec {
}

impl ExecutionPlan for EmptyExec {
fn name(&self) -> &'static str {
"EmptyExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ impl DisplayAs for ExplainExec {
}

impl ExecutionPlan for ExplainExec {
fn name(&self) -> &'static str {
"ExplainExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ impl DisplayAs for FilterExec {
}

impl ExecutionPlan for FilterExec {
fn name(&self) -> &'static str {
"FilterExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ impl DisplayAs for FileSinkExec {
}

impl ExecutionPlan for FileSinkExec {
fn name(&self) -> &'static str {
"FileSinkExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/joins/cross_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ impl DisplayAs for CrossJoinExec {
}

impl ExecutionPlan for CrossJoinExec {
fn name(&self) -> &'static str {
"CrossJoinExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/joins/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ fn project_index_to_exprs(
}

impl ExecutionPlan for HashJoinExec {
fn name(&self) -> &'static str {
"HashJoinExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/joins/nested_loop_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ impl DisplayAs for NestedLoopJoinExec {
}

impl ExecutionPlan for NestedLoopJoinExec {
fn name(&self) -> &'static str {
"NestedLoopJoinExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/joins/sort_merge_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ impl DisplayAs for SortMergeJoinExec {
}

impl ExecutionPlan for SortMergeJoinExec {
fn name(&self) -> &'static str {
"SortMergeJoinExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/joins/symmetric_hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ impl DisplayAs for SymmetricHashJoinExec {
}

impl ExecutionPlan for SymmetricHashJoinExec {
fn name(&self) -> &'static str {
"SymmetricHashJoinExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
9 changes: 9 additions & 0 deletions datafusion/physical-plan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ pub use datafusion_execution::{RecordBatchStream, SendableRecordBatchStream};
/// [`required_input_distribution`]: ExecutionPlan::required_input_distribution
/// [`required_input_ordering`]: ExecutionPlan::required_input_ordering
pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
/// Short name for the ExecutionPlan, such as 'ParquetExec'.
fn name(&self) -> &'static str {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a default impl here? the user might forget to override the name

let full_name = std::any::type_name::<Self>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that users can implement their own implementations if they don't want this method to involve any computation, nice!

let maybe_start_idx = full_name.rfind(":");
matthewmturner marked this conversation as resolved.
Show resolved Hide resolved
match maybe_start_idx {
Some(start_idx) => &full_name[start_idx + 1..],
None => "UNKNOWN",
}
}
/// Returns the execution plan as [`Any`] so that it can be
/// downcast to a specific implementation.
fn as_any(&self) -> &dyn Any;
Expand Down
8 changes: 8 additions & 0 deletions datafusion/physical-plan/src/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ impl DisplayAs for GlobalLimitExec {
}

impl ExecutionPlan for GlobalLimitExec {
fn name(&self) -> &'static str {
"GlobalLimitExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down Expand Up @@ -317,6 +321,10 @@ impl DisplayAs for LocalLimitExec {
}

impl ExecutionPlan for LocalLimitExec {
fn name(&self) -> &'static str {
"LocalLimitExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ impl DisplayAs for MemoryExec {
}

impl ExecutionPlan for MemoryExec {
fn name(&self) -> &'static str {
"MemoryExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/placeholder_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ impl DisplayAs for PlaceholderRowExec {
}

impl ExecutionPlan for PlaceholderRowExec {
fn name(&self) -> &'static str {
"PlaceholderRowExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ impl DisplayAs for ProjectionExec {
}

impl ExecutionPlan for ProjectionExec {
fn name(&self) -> &'static str {
"ProjectionExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/recursive_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ impl RecursiveQueryExec {
}

impl ExecutionPlan for RecursiveQueryExec {
fn name(&self) -> &'static str {
"RecursiveQueryExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/repartition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ impl DisplayAs for RepartitionExec {
}

impl ExecutionPlan for RepartitionExec {
fn name(&self) -> &'static str {
"RepartitionExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/sorts/partial_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ impl DisplayAs for PartialSortExec {
}

impl ExecutionPlan for PartialSortExec {
fn name(&self) -> &'static str {
"PartialSortExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/sorts/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,10 @@ impl DisplayAs for SortExec {
}

impl ExecutionPlan for SortExec {
fn name(&self) -> &'static str {
"SortExec"
}

fn as_any(&self) -> &dyn Any {
self
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/sorts/sort_preserving_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ impl DisplayAs for SortPreservingMergeExec {
}

impl ExecutionPlan for SortPreservingMergeExec {
fn name(&self) -> &'static str {
"SortPreservingMergeExec"
}

/// Return a reference to Any that can be used for downcasting
fn as_any(&self) -> &dyn Any {
self
Expand Down
Loading
Loading