@@ -128,6 +128,45 @@ pub trait WindowExpr: Send + Sync + Debug {
128
128
129
129
/// Get the reverse expression of this [WindowExpr].
130
130
fn get_reverse_expr ( & self ) -> Option < Arc < dyn WindowExpr > > ;
131
+
132
+ /// Returns all expressions used in the [`WindowExpr`].
133
+ /// These expressions are (1) function arguments, (2) partition by expressions, (3) order by expressions.
134
+ fn all_expressions ( & self ) -> WindowPhysicalExpressions {
135
+ let args = self . expressions ( ) ;
136
+ let partition_by_exprs = self . partition_by ( ) . to_vec ( ) ;
137
+ let order_by_exprs = self
138
+ . order_by ( )
139
+ . iter ( )
140
+ . map ( |sort_expr| sort_expr. expr . clone ( ) )
141
+ . collect :: < Vec < _ > > ( ) ;
142
+ WindowPhysicalExpressions {
143
+ args,
144
+ partition_by_exprs,
145
+ order_by_exprs,
146
+ }
147
+ }
148
+
149
+ /// Rewrites [`WindowExpr`], with new expressions given. The argument should be consistent
150
+ /// with the return value of the [`WindowExpr::all_expressions`] method.
151
+ /// Returns `Some(Arc<dyn WindowExpr>)` if re-write is supported, otherwise returns `None`.
152
+ fn with_new_expressions (
153
+ & self ,
154
+ _args : Vec < Arc < dyn PhysicalExpr > > ,
155
+ _partition_bys : Vec < Arc < dyn PhysicalExpr > > ,
156
+ _order_by_exprs : Vec < Arc < dyn PhysicalExpr > > ,
157
+ ) -> Option < Arc < dyn WindowExpr > > {
158
+ None
159
+ }
160
+ }
161
+
162
+ /// Stores the physical expressions used inside the `WindowExpr`.
163
+ pub struct WindowPhysicalExpressions {
164
+ /// Window function arguments
165
+ pub args : Vec < Arc < dyn PhysicalExpr > > ,
166
+ /// PARTITION BY expressions
167
+ pub partition_by_exprs : Vec < Arc < dyn PhysicalExpr > > ,
168
+ /// ORDER BY expressions
169
+ pub order_by_exprs : Vec < Arc < dyn PhysicalExpr > > ,
131
170
}
132
171
133
172
/// Extension trait that adds common functionality to [`AggregateWindowExpr`]s
0 commit comments