| 1615 | |
| 1616 | template <typename ArrowType> |
| 1617 | class TestFirstLastKernel : public ::testing::Test { |
| 1618 | using Traits = TypeTraits<ArrowType>; |
| 1619 | using ArrayType = typename Traits::ArrayType; |
| 1620 | using c_type = typename ArrowType::c_type; |
| 1621 | using ScalarType = typename Traits::ScalarType; |
| 1622 | |
| 1623 | public: |
| 1624 | void AssertFirstLastIs(const Datum& array, c_type expected_first, c_type expected_last, |
| 1625 | const ScalarAggregateOptions& options) { |
| 1626 | ASSERT_OK_AND_ASSIGN(Datum out, CallFunction("first", {array}, &options)); |
| 1627 | const auto& out_first = out.scalar_as<ScalarType>(); |
| 1628 | ASSERT_EQ(expected_first, out_first.value); |
| 1629 | |
| 1630 | ASSERT_OK_AND_ASSIGN(out, CallFunction("last", {array}, &options)); |
| 1631 | const auto& out_last = out.scalar_as<ScalarType>(); |
| 1632 | ASSERT_EQ(expected_last, out_last.value); |
| 1633 | } |
| 1634 | |
| 1635 | void AssertFirstLastIsNull(const Datum& array, const ScalarAggregateOptions& options) { |
| 1636 | ASSERT_OK_AND_ASSIGN(Datum out, First(array, options)); |
| 1637 | const auto& out_first = out.scalar_as<ScalarType>(); |
| 1638 | ASSERT_FALSE(out_first.is_valid); |
| 1639 | |
| 1640 | ASSERT_OK_AND_ASSIGN(out, Last(array, options)); |
| 1641 | const auto& out_last = out.scalar_as<ScalarType>(); |
| 1642 | ASSERT_FALSE(out_last.is_valid); |
| 1643 | } |
| 1644 | |
| 1645 | void AssertFirstLastIsNull(const std::string& json, |
| 1646 | const ScalarAggregateOptions& options) { |
nothing calls this directly
no test coverage detected