pitrou commented on a change in pull request #11525:
URL: https://github.com/apache/arrow/pull/11525#discussion_r745852960
##########
File path: cpp/src/arrow/compute/kernels/scalar_if_else.cc
##########
@@ -1302,7 +1304,8 @@ struct CopyFixedWidth<BooleanType> {
};
template <typename Type>
-struct CopyFixedWidth<Type, enable_if_number<Type>> {
+struct CopyFixedWidth<
+ Type, enable_if_t<is_number_type<Type>::value ||
is_interval_type<Type>::value>> {
Review comment:
Out of curiosity, why `is_interval_type` here while IfElseFunctor only
allows month-day-nano intervals?
##########
File path: cpp/src/arrow/compute/kernels/vector_replace_test.cc
##########
@@ -580,6 +588,80 @@ TEST_F(TestReplaceDayTimeInterval, ReplaceWithMask) {
this->array("[[7, 8], [3, 4], null]"));
}
+TEST_F(TestReplaceMonthDayNanoInterval, ReplaceWithMask) {
+ this->Assert(ReplaceWithMask, this->array("[]"), this->mask_scalar(false),
+ this->array("[]"), this->array("[]"));
+ this->Assert(ReplaceWithMask, this->array("[]"), this->mask_scalar(true),
+ this->array("[]"), this->array("[]"));
+ this->Assert(ReplaceWithMask, this->array("[]"), this->null_mask_scalar(),
+ this->array("[]"), this->array("[]"));
+
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4]]"),
this->mask_scalar(false),
+ this->array("[]"), this->array("[[1, 2, 4]]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4]]"),
this->mask_scalar(true),
+ this->array("[[3, 4, -2]]"), this->array("[[3, 4, -2]]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4]]"),
this->null_mask_scalar(),
+ this->array("[]"), this->array("[null]"));
+
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [3, 4, -2]]"),
+ this->mask_scalar(false), this->scalar("[7, 0, 8]"),
+ this->array("[[1, 2, 4], [3, 4, -2]]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [3, 4, -2]]"),
+ this->mask_scalar(true), this->scalar("[7, 0, 8]"),
+ this->array("[[7, 0, 8], [7, 0, 8]]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [3, 4, -2]]"),
+ this->mask_scalar(true), this->scalar("null"),
+ this->array("[null, null]"));
+
+ this->Assert(ReplaceWithMask, this->array("[]"), this->mask("[]"),
this->array("[]"),
+ this->array("[]"));
+ this->Assert(ReplaceWithMask,
+ this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4], [1, 2, 4]]"),
+ this->mask("[false, false, false, false]"), this->array("[]"),
+ this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4], [1, 2, 4]]"));
+ this->Assert(ReplaceWithMask,
+ this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4], [1, 2, 4]]"),
+ this->mask("[true, true, true, true]"),
+ this->array("[[3, 4, -2], [3, 4, -2], [3, 4, -2], [3, 4, -2]]"),
+ this->array("[[3, 4, -2], [3, 4, -2], [3, 4, -2], [3, 4,
-2]]"));
+ this->Assert(ReplaceWithMask,
+ this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4], [1, 2, 4]]"),
+ this->mask("[null, null, null, null]"), this->array("[]"),
+ this->array("[null, null, null, null]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4],
null]"),
+ this->mask("[false, false, false, false]"), this->array("[]"),
+ this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4], null]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4],
null]"),
+ this->mask("[true, true, true, true]"),
+ this->array("[[3, 4, -2], [3, 4, -2], [3, 4, -2], [3, 4, -2]]"),
+ this->array("[[3, 4, -2], [3, 4, -2], [3, 4, -2], [3, 4,
-2]]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4],
null]"),
+ this->mask("[null, null, null, null]"), this->array("[]"),
+ this->array("[null, null, null, null]"));
+ this->Assert(
+ ReplaceWithMask,
+ this->array("[[1, 2, 4], [1, 2, 4], [1, 2, 4], [1, 2, 4], [1, 2, 4], [1,
2, 4]]"),
+ this->mask("[true, true, false, false, null, null]"),
+ this->array("[[3, 4, -2], null]"),
+ this->array("[[3, 4, -2], null, [1, 2, 4], [1, 2, 4], null, null]"));
+ this->Assert(ReplaceWithMask, this->array("[null, null, null, null, null,
null]"),
+ this->mask("[true, true, false, false, null, null]"),
+ this->array("[[3, 4, -2], null]"),
+ this->array("[[3, 4, -2], null, null, null, null, null]"));
+
+ this->Assert(ReplaceWithMask, this->array("[]"), this->mask("[]"),
+ this->scalar("[7, 0, 8]"), this->array("[]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [3, 4, -2]]"),
+ this->mask("[true, true]"), this->scalar("[7, 0, 8]"),
+ this->array("[[7, 0, 8], [7, 0, 8]]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [3, 4, -2]]"),
+ this->mask("[true, true]"), this->scalar("null"),
+ this->array("[null, null]"));
+ this->Assert(ReplaceWithMask, this->array("[[1, 2, 4], [3, 4, -2], [-5, 6,
7]]"),
+ this->mask("[true, false, null]"), this->scalar("[7, 0, 8]"),
Review comment:
Slightly unrelated to this PR, but it seems that amongst the
`ReplaceWithMask` tests, the mask is always of the form (regex) `true*
(false|null)*`, meaning that the replacement index is always trivially equal to
the source index. Is that deliberate?
--
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]