waynexia opened a new issue, #10246:
URL: https://github.com/apache/datafusion/issues/10246
### Is your feature request related to a problem or challenge?
Come across on reviewing #9793
### Describe the solution you'd like
The newly added `ExecutionPlan::name()` method receives a `&self` as param.
In some scenarios it might not be very easy to construct an instance of
`ExecutionPlan` as it usually requires some verbose state. If one wants to just
use the plan's name as a static string (like the replacement of `static NAME:
&'static str = "xxx";`), they have to construct an instance first.
The `ExecutionPlan::name()` method can be a static method, i.e., without
receiving a `&self`. However, removing the parameter seems not acceptable, or
this method cannot be called via an instant but only from a type like
`MyPlan::name()`. Thus this ticket proposes to add a new static one along with
the member one. We can use one to implement another like this
```rust
pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
/// Short name for the ExecutionPlan, such as 'ParquetExec'.
fn name(&self) -> &'static str
where
Self: Sized,
{
Self::static_name()
}
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 {
Some(start_idx) => &full_name[start_idx + 1..],
None => "UNKNOWN",
}
}
}
```
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]