apache / datafusion

Apache DataFusion SQL Query Engine
https://datafusion.apache.org/
Apache License 2.0
5.92k stars 1.12k forks source link

Public some fields for about functions #4029

Open YjyJeff opened 1 year ago

YjyJeff commented 1 year ago

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Hi, I want to serialize/deserialize the physical plan into protobuf such that the PhysicalPlan can be transmitted between different computers. Firstly, I took a look at the ballista and find that most of the physical plan/expressions are supported, great! Then I want to add more features above it, like encoding WindowAggExec into protobuf. The problem is that I can not get the expr field in BuiltInWindowExpr and aggregate field in AggregateWindowExpr, then I can not encode/serialize these functions.....

Describe the solution you'd like

Add public methods to these fields such that users can access them. The following methods are needed, currently:

impl BuiltInWindowExpr{
    fn expr(&self) -> &dyn BuiltInWindowFunctionExpr{
        &*self.expr
    }
}

impl AggregateWindowExpr{
    fn aggregate(&self) -> &dyn AggregateExpr{
        &*self.aggregate
    }
}

impl AggregateFunctionExpr{
    fn fun(&self) -> &AggregateUDF{
        &self.fun
    }
}

pub trait BuiltInWindowFunctionExpr{
    // old methods
    // New method
   fn builtin_window_function(&self) -> BuiltInWindowFunction;
}

The request is pretty simple, I would like to add these methods if you are agreed. What's more, I would appreciate the advice that can do the same work without adding these methods.

Thanks in advance, sincerely

alamb commented 1 year ago

The request is pretty simple, I would like to add these methods if you are agreed. What's more, I would appreciate the advice that can do the same work without adding these methods.

Sounds reasonable to me

alamb commented 1 year ago

Possibly related https://github.com/apache/arrow-datafusion/issues/3257