You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
idea: add another static_name() method to ExecutionPlan trait #10246
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
pubtraitExecutionPlan:Debug + DisplayAs + Send + Sync{/// Short name for the ExecutionPlan, such as 'ParquetExec'.fnname(&self) -> &'staticstrwhereSelf:Sized,{Self::static_name()}fnstatic_name() -> &'staticstrwhereSelf: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",}}}
Activity
waynexia commentedon Apr 26, 2024
cc @matthewmturner and @comphead from #9793
waynexia commentedon Apr 26, 2024
I have a similar pattern on implementing user defined logical plan:
https://github.com/GreptimeTeam/greptimedb/blob/4eadd9f8a88870fff72922d9c7515cf29bc790b3/src/promql/src/extension_plan/empty_metric.rs#L130-L133
where
comphead commentedon Apr 26, 2024
Thanks @waynexia could you please give an example how the static be called for different plan nodes to obtain different names?
waynexia commentedon Apr 27, 2024
This (old) test case can be an example: https://github.com/apache/datafusion/pull/10266/files#diff-9f1cf112a3f7c21baab307b9001331d287479e54e60b594712395052e0ad0690R935-R936
After #10266 the call to
ExecutionPlan::name()is proxied tostatic_name()in default implementation.