| 1575 | |
| 1576 | template <typename ArrowType> |
| 1577 | class TestFirstLastKernel : public ::testing::Test { |
| 1578 | using Traits = TypeTraits<ArrowType>; |
| 1579 | using ArrayType = typename Traits::ArrayType; |
| 1580 | using c_type = typename ArrowType::c_type; |
| 1581 | using ScalarType = typename Traits::ScalarType; |
| 1582 | |
| 1583 | public: |
| 1584 | void AssertFirstLastIs(const Datum& array, c_type expected_first, c_type expected_last, |
| 1585 | const ScalarAggregateOptions& options) { |
| 1586 | ASSERT_OK_AND_ASSIGN(Datum out, CallFunction("first", {array}, &options)); |
| 1587 | const auto& out_first = out.scalar_as<ScalarType>(); |
| 1588 | ASSERT_EQ(expected_first, out_first.value); |
| 1589 | |
| 1590 | ASSERT_OK_AND_ASSIGN(out, CallFunction("last", {array}, &options)); |
| 1591 | const auto& out_last = out.scalar_as<ScalarType>(); |
| 1592 | ASSERT_EQ(expected_last, out_last.value); |
| 1593 | } |
| 1594 | |
| 1595 | void AssertFirstLastIsNull(const Datum& array, const ScalarAggregateOptions& options) { |
| 1596 | ASSERT_OK_AND_ASSIGN(Datum out, First(array, options)); |
| 1597 | const auto& out_first = out.scalar_as<ScalarType>(); |
| 1598 | ASSERT_FALSE(out_first.is_valid); |
| 1599 | |
| 1600 | ASSERT_OK_AND_ASSIGN(out, Last(array, options)); |
| 1601 | const auto& out_last = out.scalar_as<ScalarType>(); |
| 1602 | ASSERT_FALSE(out_last.is_valid); |
| 1603 | } |
| 1604 | |
| 1605 | void AssertFirstLastIsNull(const std::string& json, |
| 1606 | const ScalarAggregateOptions& options) { |
nothing calls this directly
no test coverage detected