MCPcopy Create free account
hub / github.com/apache/datafusion / unproject_window_exprs

Function unproject_window_exprs

datafusion/sql/src/unparser/utils.rs:253–266  ·  view source on GitHub ↗

Recursively identify all Column expressions and transform them into the appropriate window expression contained in window. For example, if expr contains the column expr "COUNT(*) PARTITION BY id" it will be transformed into an actual window expression as identified in the window node.

(expr: Expr, windows: &[&Window])

Source from the content-addressed store, hash-verified

251/// For example, if expr contains the column expr "COUNT(*) PARTITION BY id" it will be transformed
252/// into an actual window expression as identified in the window node.
253pub(crate) fn unproject_window_exprs(expr: Expr, windows: &[&Window]) -> Result<Expr> {
254 expr.transform(|sub_expr| {
255 if let Expr::Column(c) = sub_expr {
256 if let Some(unproj) = find_window_expr(windows, &c.name) {
257 Ok(Transformed::yes(unproj.clone()))
258 } else {
259 Ok(Transformed::no(Expr::Column(c)))
260 }
261 } else {
262 Ok(Transformed::no(sub_expr))
263 }
264 })
265 .map(|e| e.data)
266}
267
268fn find_agg_expr<'a>(agg: &'a Aggregate, column: &Column) -> Result<Option<&'a Expr>> {
269 if let Ok(index) = agg.schema.index_of_column(column) {

Callers 2

Calls 5

find_window_exprFunction · 0.85
ColumnClass · 0.50
mapMethod · 0.45
transformMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…