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

Function create_udwf_window_expr

datafusion/physical-plan/src/windows/mod.rs:170–206  ·  view source on GitHub ↗

Creates a `StandardWindowFunctionExpr` suitable for a user defined window function

(
    fun: &Arc<WindowUDF>,
    args: &[Arc<dyn PhysicalExpr>],
    input_schema: &Schema,
    name: String,
    ignore_nulls: bool,
)

Source from the content-addressed store, hash-verified

168
169/// Creates a `StandardWindowFunctionExpr` suitable for a user defined window function
170pub fn create_udwf_window_expr(
171 fun: &Arc<WindowUDF>,
172 args: &[Arc<dyn PhysicalExpr>],
173 input_schema: &Schema,
174 name: String,
175 ignore_nulls: bool,
176) -> Result<Arc<dyn StandardWindowFunctionExpr>> {
177 // need to get the types into an owned vec for some reason
178 let input_fields: Vec<_> = args
179 .iter()
180 .map(|arg| arg.return_field(input_schema))
181 .collect::<Result<_>>()?;
182
183 let udwf_expr = Arc::new(WindowUDFExpr {
184 fun: Arc::clone(fun),
185 args: args.to_vec(),
186 input_fields,
187 name,
188 is_reversed: false,
189 ignore_nulls,
190 });
191
192 // Early validation of input expressions
193 // We create a partition evaluator because in the user-defined window
194 // implementation this is where code for parsing input expressions
195 // exist. The benefits are:
196 // - If any of the input expressions are invalid we catch them early
197 // in the planning phase, rather than during execution.
198 // - Maintains compatibility with built-in (now removed) window
199 // functions validation behavior.
200 // - Predictable and reliable error handling.
201 // See discussion here:
202 // https://github.com/apache/datafusion/pull/13201#issuecomment-2454209975
203 let _ = udwf_expr.create_evaluator()?;
204
205 Ok(udwf_expr)
206}
207
208/// Implements [`StandardWindowFunctionExpr`] for [`WindowUDF`]
209#[derive(Clone, Debug)]

Callers 12

create_window_exprFunction · 0.85
roundtrip_udwfFunction · 0.85
roundtrip_windowFunction · 0.85
build_window_topn_planFunction · 0.85
flipped_3_gteq_rnFunction · 0.85
with_projection_betweenFunction · 0.85
build_window_planFunction · 0.85

Calls 6

newFunction · 0.85
to_vecMethod · 0.80
create_evaluatorMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
return_fieldMethod · 0.45

Tested by 10

roundtrip_udwfFunction · 0.68
roundtrip_windowFunction · 0.68
build_window_topn_planFunction · 0.68
flipped_3_gteq_rnFunction · 0.68
with_projection_betweenFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…