edponce commented on a change in pull request #12014:
URL: https://github.com/apache/arrow/pull/12014#discussion_r794797795
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -182,6 +188,9 @@ static std::shared_ptr<NumericArray<ArrowType>>
GenerateNumericArray(int64_t siz
buffers[1] = *AllocateBuffer(sizeof(CType) * size);
options.GenerateData(buffers[1]->mutable_data(), size);
+ if (std::is_same<ArrowType, Date64Type>::value) {
+ GenerateFullDayMillisNoNan(buffers[1]->mutable_data(), size);
+ }
Review comment:
This should be an if-else. `buffers[1]->mutable_data()` is modified
twice if `Date64Type`.
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -772,12 +789,42 @@ std::shared_ptr<Array>
RandomArrayGenerator::ArrayOf(const Field& field, int64_t
}
GENERATE_INTEGRAL_CASE_VIEW(Int32Type, Date32Type);
- GENERATE_INTEGRAL_CASE_VIEW(Int64Type, Date64Type);
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, TimestampType);
- GENERATE_INTEGRAL_CASE_VIEW(Int32Type, Time32Type);
- GENERATE_INTEGRAL_CASE_VIEW(Int64Type, Time64Type);
GENERATE_INTEGRAL_CASE_VIEW(Int32Type, MonthIntervalType);
+ case Type::type::DATE64: {
+ using c_type = typename Date64Type::c_type;
+ constexpr c_type kFullDayMillis = 1000 * 60 * 60 * 24;
+ constexpr c_type min_value = std::numeric_limits<c_type>::min() /
kFullDayMillis;
+ constexpr c_type max_value = std::numeric_limits<c_type>::max() /
kFullDayMillis;
Review comment:
`std::numeric_limits<int64_t>::min()` would allow negative values, so
maybe set to 0.
Although, there are tests with negative `Date64Type` values.
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -182,6 +188,9 @@ static std::shared_ptr<NumericArray<ArrowType>>
GenerateNumericArray(int64_t siz
buffers[1] = *AllocateBuffer(sizeof(CType) * size);
options.GenerateData(buffers[1]->mutable_data(), size);
+ if (std::is_same<ArrowType, Date64Type>::value) {
+ GenerateFullDayMillisNoNan(buffers[1]->mutable_data(), size);
+ }
Review comment:
I think a more suitable place for this type-specific generation of
numeric arrays, is in [`GenerateTypeDataNoNan()` from
`GenerateOptions`](https://github.com/apache/arrow/pull/12014/files#diff-a128a62d4300b880f0c4652a53eaae67f4ff3fa0a6bd3ad8d6bc15e2930f3e6aR97).
Make
[`GenerateFullDayMillisNoNan`](https://github.com/apache/arrow/pull/12014/files#diff-a128a62d4300b880f0c4652a53eaae67f4ff3fa0a6bd3ad8d6bc15e2930f3e6aR172)
as a private member to `GenerateOptions` and perform the `if-else` check in
`GenerateTypedDataNoNan()`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]