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

Method register

datafusion/core/tests/user_defined/user_defined_aggregates.rs:576–602  ·  view source on GitHub ↗
(ctx: &mut SessionContext, test_state: Arc<TestState>, name: &str)

Source from the content-addressed store, hash-verified

574
575 #[expect(clippy::needless_pass_by_value)]
576 fn register(ctx: &mut SessionContext, test_state: Arc<TestState>, name: &str) {
577 let timestamp_type = DataType::Timestamp(TimeUnit::Nanosecond, None);
578 let input_type = vec![timestamp_type.clone()];
579
580 // Returns the same type as its input
581 let return_type = timestamp_type.clone();
582
583 let state_fields = vec![Field::new("sum", timestamp_type, true).into()];
584
585 let volatility = Volatility::Immutable;
586
587 let captured_state = Arc::clone(&test_state);
588 let accumulator: AccumulatorFactoryFunction =
589 Arc::new(move |_| Ok(Box::new(Self::new(Arc::clone(&captured_state)))));
590
591 let time_sum = AggregateUDF::from(SimpleAggregateUDF::new(
592 name,
593 input_type,
594 return_type,
595 volatility,
596 accumulator,
597 state_fields,
598 ));
599
600 // register the selector as "time_sum"
601 ctx.register_udaf(time_sum)
602 }
603}
604
605impl Accumulator for TimeSum {

Calls 7

newFunction · 0.85
TimestampClass · 0.50
cloneMethod · 0.45
register_udafMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
intoMethod · 0.45

Tested by

no test coverage detected