| 527 | } |
| 528 | |
| 529 | Status Finalize(KernelContext*, Datum* out) override { |
| 530 | const auto& struct_type = checked_cast<const StructType&>(*out_type); |
| 531 | const auto& child_type = struct_type.field(0)->type(); |
| 532 | auto null_scalar = MakeNullScalar(child_type); |
| 533 | |
| 534 | std::vector<std::shared_ptr<Scalar>> values; |
| 535 | |
| 536 | if (this->count < options.min_count) { |
| 537 | values = {null_scalar, null_scalar}; |
| 538 | } else { |
| 539 | if (state.has_values) { |
| 540 | if (options.skip_nulls) { |
| 541 | ARROW_ASSIGN_OR_RAISE(auto first_scalar, MakeScalar(child_type, state.first)); |
| 542 | ARROW_ASSIGN_OR_RAISE(auto last_scalar, MakeScalar(child_type, state.last)); |
| 543 | values = {first_scalar, last_scalar}; |
| 544 | } else { |
| 545 | ARROW_ASSIGN_OR_RAISE( |
| 546 | auto first_scalar, |
| 547 | state.first_is_null ? null_scalar : MakeScalar(child_type, state.first)); |
| 548 | ARROW_ASSIGN_OR_RAISE( |
| 549 | auto last_scalar, |
| 550 | state.last_is_null ? null_scalar : MakeScalar(child_type, state.last)); |
| 551 | |
| 552 | values = {first_scalar, last_scalar}; |
| 553 | } |
| 554 | } else { |
| 555 | // If there is no non-null values, we always output null regardless of |
| 556 | // skip_null |
| 557 | values = {null_scalar, null_scalar}; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | out->value = std::make_shared<StructScalar>(std::move(values), this->out_type); |
| 562 | return Status::OK(); |
| 563 | } |
| 564 | |
| 565 | std::shared_ptr<DataType> out_type; |
| 566 | ScalarAggregateOptions options; |
nothing calls this directly
no test coverage detected