lidavidm commented on a change in pull request #12014:
URL: https://github.com/apache/arrow/pull/12014#discussion_r794516464
##########
File path: cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
##########
@@ -1652,13 +1693,7 @@ TEST(GroupBy, MinMaxTypes) {
field("hash_min_max", struct_({field("min", ty), field("max",
ty)})),
field("key_0", int64()),
}),
- R"([
- [{"min": 1, "max": 3}, 1],
- [{"min": 0, "max": 0}, 2],
- [{"min": null, "max": null}, 3],
- [{"min": 3, "max": 5}, 4],
- [{"min": 1, "max": 4}, null]
- ])"),
+ (ty->name() == "date64") ? date64_expected : default_expected),
Review comment:
nit: ditto here
##########
File path: cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
##########
@@ -1632,11 +1630,54 @@ TEST(GroupBy, MinMaxTypes) {
[3, 1],
[0, 2]
])",
- R"([
+ R"([
[0, 2],
[1, null],
[null, 3]
-])"});
+])"};
+
+ const std::vector<std::string> date64_table = {R"([
+ [86400000, 1],
+ [null, 1]
+])",
+ R"([
+ [0, 2],
+ [null, 3],
+ [259200000, 4],
+ [432000000, 4],
+ [345600000, null],
+ [259200000, 1],
+ [0, 2]
+])",
+ R"([
+ [0, 2],
+ [86400000, null],
+ [null, 3]
+])"};
+
+ const std::string default_expected =
+ R"([
+ [{"min": 1, "max": 3}, 1],
+ [{"min": 0, "max": 0}, 2],
+ [{"min": null, "max": null}, 3],
+ [{"min": 3, "max": 5}, 4],
+ [{"min": 1, "max": 4}, null]
+ ])";
+
+ const std::string date64_expected =
+ R"([
+ [{"min": 86400000, "max": 259200000}, 1],
+ [{"min": 0, "max": 0}, 2],
+ [{"min": null, "max": null}, 3],
+ [{"min": 259200000, "max": 432000000}, 4],
+ [{"min": 86400000, "max": 345600000}, null]
+ ])";
+
+ for (const auto& ty : types) {
+ SCOPED_TRACE(ty->ToString());
+ auto in_schema = schema({field("argument0", ty), field("key", int64())});
+ auto table =
+ TableFromJSON(in_schema, (ty->name() == "date64") ? date64_table :
default_table);
Review comment:
nit: can check `ty->id() == Type::DATE64`
##########
File path: cpp/src/arrow/compute/kernels/vector_hash_test.cc
##########
@@ -161,42 +161,95 @@ TYPED_TEST_SUITE(TestHashKernelPrimitive,
PrimitiveDictionaries);
TYPED_TEST(TestHashKernelPrimitive, Unique) {
using T = typename TypeParam::c_type;
auto type = TypeTraits<TypeParam>::type_singleton();
- CheckUnique<TypeParam, T>(type, {2, 1, 2, 1}, {true, false, true, true}, {2,
0, 1},
- {1, 0, 1});
- CheckUnique<TypeParam, T>(type, {2, 1, 3, 1}, {false, false, true, true},
{0, 3, 1},
- {0, 1, 1});
- // Sliced
- CheckUnique(ArrayFromJSON(type, "[1, 2, null, 3, 2, null]")->Slice(1, 4),
- ArrayFromJSON(type, "[2, null, 3]"));
+ if (type->name() == "date64") {
Review comment:
and here and so on (sorry)
##########
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;
+
+ return *Numeric<Date64Type>(length, min_value, max_value,
null_probability)
+ ->View(field.type());
+ }
+
+ case Type::type::TIME32: {
+ TimeUnit::type unit =
std::dynamic_pointer_cast<Time32Type>(field.type())->unit();
Review comment:
nit: we have `internal::checked_[pointer_]cast` which will use dynamic
or static cast depending on debug/release build
--
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]