This is an automated email from the ASF dual-hosted git repository.

wayne pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new c963d21340 feat: add static_name() to ExecutionPlan (#10266)
c963d21340 is described below

commit c963d2134020b2a92ed398295448becae3cb6ce5
Author: Ruihang Xia <[email protected]>
AuthorDate: Mon Apr 29 20:54:04 2024 +0800

    feat: add static_name() to ExecutionPlan (#10266)
    
    * feat: add static_name() to ExecutionPlan
    
    Signed-off-by: Ruihang Xia <[email protected]>
    
    * add test to invoke from type
    
    Signed-off-by: Ruihang Xia <[email protected]>
    
    ---------
    
    Signed-off-by: Ruihang Xia <[email protected]>
---
 datafusion/physical-plan/src/lib.rs                 | 21 +++++++++++++++++++--
 .../src/repartition/distributor_channels.rs         |  2 +-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/datafusion/physical-plan/src/lib.rs 
b/datafusion/physical-plan/src/lib.rs
index e1c8489655..cd2be33e86 100644
--- a/datafusion/physical-plan/src/lib.rs
+++ b/datafusion/physical-plan/src/lib.rs
@@ -117,7 +117,19 @@ pub mod udaf {
 /// [`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 {
+    fn name(&self) -> &'static str
+    where
+        Self: Sized,
+    {
+        Self::static_name()
+    }
+
+    /// Short name for the ExecutionPlan, such as 'ParquetExec'.
+    /// Like [`name`](ExecutionPlan::name) but can be called without an 
instance.
+    fn static_name() -> &'static str
+    where
+        Self: Sized,
+    {
         let full_name = std::any::type_name::<Self>();
         let maybe_start_idx = full_name.rfind(':');
         match maybe_start_idx {
@@ -125,6 +137,7 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
             None => "UNKNOWN",
         }
     }
+
     /// Returns the execution plan as [`Any`] so that it can be
     /// downcast to a specific implementation.
     fn as_any(&self) -> &dyn Any;
@@ -873,7 +886,10 @@ mod tests {
     }
 
     impl ExecutionPlan for RenamedEmptyExec {
-        fn name(&self) -> &'static str {
+        fn static_name() -> &'static str
+        where
+            Self: Sized,
+        {
             "MyRenamedEmptyExec"
         }
 
@@ -918,6 +934,7 @@ mod tests {
         let schema2 = Arc::new(Schema::empty());
         let renamed_exec = RenamedEmptyExec::new(schema2);
         assert_eq!(renamed_exec.name(), "MyRenamedEmptyExec");
+        assert_eq!(RenamedEmptyExec::static_name(), "MyRenamedEmptyExec");
     }
 }
 
diff --git a/datafusion/physical-plan/src/repartition/distributor_channels.rs 
b/datafusion/physical-plan/src/repartition/distributor_channels.rs
index bad923ce9e..675d26bbfb 100644
--- a/datafusion/physical-plan/src/repartition/distributor_channels.rs
+++ b/datafusion/physical-plan/src/repartition/distributor_channels.rs
@@ -474,7 +474,7 @@ type SharedGate = Arc<Gate>;
 
 #[cfg(test)]
 mod tests {
-    use std::sync::atomic::{AtomicBool, Ordering};
+    use std::sync::atomic::AtomicBool;
 
     use futures::{task::ArcWake, FutureExt};
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to