(ctx: &mut SessionContext, test_state: Arc<TestState>, name: &str)
| 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 | |
| 605 | impl Accumulator for TimeSum { |
no test coverage detected