emkornfield commented on a change in pull request #10177: URL: https://github.com/apache/arrow/pull/10177#discussion_r690515104
########## File path: cpp/src/arrow/type.h ########## @@ -1317,6 +1317,40 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType { std::string name() const override { return "day_time_interval"; } }; +/// \brief Represents a number of days and milliseconds (fraction of day). +class ARROW_EXPORT MonthDayNanoIntervalType : public IntervalType { + public: + struct MonthDayNanos { + int32_t months; + int32_t days; + int64_t nanoseconds; + bool operator==(MonthDayNanos other) const { + return this->months == other.months && this->days == other.days && + this->nanoseconds == other.nanoseconds; + } + bool operator!=(MonthDayNanos other) const { return !(*this == other); } + }; + using c_type = MonthDayNanos; + using PhysicalType = MonthDayNanoIntervalType; + + static_assert(sizeof(MonthDayNanos) == 16, + "MonthDayNanos struct assumed to be of size 8 bytes"); Review comment: done. ########## File path: cpp/src/arrow/array/array_primitive.h ########## @@ -132,4 +136,33 @@ class ARROW_EXPORT DayTimeIntervalArray : public PrimitiveArray { const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); } }; +/// \brief Array of Month, Day and nanosecond values. +class ARROW_EXPORT MonthDayNanoIntervalArray : public PrimitiveArray { + public: + using TypeClass = MonthDayNanoIntervalType; + + explicit MonthDayNanoIntervalArray(const std::shared_ptr<ArrayData>& data); + + MonthDayNanoIntervalArray(const std::shared_ptr<DataType>& type, int64_t length, + const std::shared_ptr<Buffer>& data, + const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, + int64_t null_count = kUnknownNullCount, int64_t offset = 0); + + MonthDayNanoIntervalArray(int64_t length, const std::shared_ptr<Buffer>& data, + const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, + int64_t null_count = kUnknownNullCount, int64_t offset = 0); + + TypeClass::MonthDayNanos GetValue(int64_t i) const; + TypeClass::MonthDayNanos Value(int64_t i) const { return GetValue(i); } + + // For compatibility with Take kernel. + TypeClass::MonthDayNanos GetView(int64_t i) const { return GetValue(i); } + + int32_t byte_width() const { return sizeof(TypeClass::MonthDayNanos); } + static_assert(sizeof(TypeClass::MonthDayNanos) == 16, + "MonthDayNanos should only take 16 bytes"); Review comment: removed. ########## File path: cpp/src/arrow/array/array_test.cc ########## @@ -1332,12 +1366,16 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesLazyIter) { } TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesIterConverted) { - DECL_T(); + typedef typename TestFixture::CType T; // find type we can safely convert the tested values to and from - using conversion_type = - typename std::conditional<std::is_floating_point<T>::value, double, - typename std::conditional<std::is_unsigned<T>::value, - uint64_t, int64_t>::type>::type; + using conversion_type = typename std::conditional< + std::is_floating_point<T>::value, double, + typename std::conditional< + std::is_same<T, DayTimeIntervalType::DayMilliseconds>::value || + std::is_same<T, MonthDayNanoIntervalType::MonthDayNanos>::value, + T, + typename std::conditional<std::is_unsigned<T>::value, uint64_t, + int64_t>::type>::type>::type; Review comment: done. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org