waynexia opened a new issue, #5449:
URL: https://github.com/apache/arrow-datafusion/issues/5449

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   A clear and concise description of what the problem is. Ex. I'm always 
frustrated when [...] 
   (This section helps Arrow developers understand the context and *why* for 
this feature, in addition to  the *what*)
   
   `ExtensionPlanner` convert extension `UserDefinedLogicalNode` to physical 
plan. But currently `UserDefinedLogicalNode` doesn't have a method to recognize 
which extension plan it is. So we have to write something like 
[this](https://github.com/GreptimeTeam/greptimedb/blob/56af23002c007ec84b6c2798e70acb59f3bd2781/src/promql/src/extension_plan/planner.rs#L31-L54):
   
   ```rust
           if let Some(node) = node.as_any().downcast_ref::<SeriesNormalize>() {
               Ok(Some(node.to_execution_plan(physical_inputs[0].clone())))
           } else if let Some(node) = 
node.as_any().downcast_ref::<InstantManipulate>() {
               Ok(Some(node.to_execution_plan(physical_inputs[0].clone())))
           } else if let Some(node) = 
node.as_any().downcast_ref::<RangeManipulate>() {
               Ok(Some(node.to_execution_plan(physical_inputs[0].clone())))
           } else if let Some(node) = 
node.as_any().downcast_ref::<SeriesDivide>() {
               Ok(Some(node.to_execution_plan(physical_inputs[0].clone())))
           } else if let Some(node) = 
node.as_any().downcast_ref::<EmptyMetric>() {
               Ok(Some(node.to_execution_plan()))
           } else {
               Ok(None)
           }
   ```
   
   **Describe the solution you'd like**
   A clear and concise description of what you want to happen.
   
   Add a new method to `UserDefinedLogicalNode` that allows it to state its 
name, like 
   ```rust
   pub trait UserDefinedLogicalNode {
     fn name(&self) -> &str;
   }
   ```
   Then the long if-else chain can be organized into `match`. It should be more 
clear.
   
   **Describe alternatives you've considered**
   A clear and concise description of any alternative solutions or features 
you've considered.
   
   **Additional context**
   Add any other context or screenshots about the feature request here.
   


-- 
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]

Reply via email to