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

Method partition_evaluator

datafusion/functions-window/src/nth_value.rs:261–308  ·  view source on GitHub ↗
(
        &self,
        partition_evaluator_args: PartitionEvaluatorArgs,
    )

Source from the content-addressed store, hash-verified

259 }
260
261 fn partition_evaluator(
262 &self,
263 partition_evaluator_args: PartitionEvaluatorArgs,
264 ) -> Result<Box<dyn PartitionEvaluator>> {
265 let state = NthValueState {
266 finalized_result: None,
267 kind: self.kind,
268 };
269
270 if self.kind != NthValueKind::Nth {
271 return Ok(Box::new(NthValueEvaluator {
272 state,
273 ignore_nulls: partition_evaluator_args.ignore_nulls(),
274 n: 0,
275 }));
276 }
277
278 let n = match get_scalar_value_from_args(
279 partition_evaluator_args.input_exprs(),
280 1,
281 )
282 .map_err(|_e| {
283 exec_datafusion_err!(
284 "Expected a signed integer literal for the second argument of nth_value"
285 )
286 })?
287 .map(|v| get_signed_integer(&v))
288 {
289 Some(Ok(n)) => {
290 if partition_evaluator_args.is_reversed() {
291 -n
292 } else {
293 n
294 }
295 }
296 _ => {
297 return exec_err!(
298 "Expected a signed integer literal for the second argument of nth_value"
299 );
300 }
301 };
302
303 Ok(Box::new(NthValueEvaluator {
304 state,
305 ignore_nulls: partition_evaluator_args.ignore_nulls(),
306 n,
307 }))
308 }
309
310 fn field(&self, field_args: WindowUDFFieldArgs) -> Result<FieldRef> {
311 let input_field =

Callers 1

test_i32_resultFunction · 0.45

Calls 7

newFunction · 0.85
get_signed_integerFunction · 0.85
ignore_nullsMethod · 0.45
mapMethod · 0.45
input_exprsMethod · 0.45
is_reversedMethod · 0.45

Tested by 1

test_i32_resultFunction · 0.36