You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/22 14:39:27 UTC
[GitHub] [arrow] lidavidm commented on a change in pull request #12215: ARROW-14101: [C++] multiply(duration, integer) -> duration kernel
lidavidm commented on a change in pull request #12215:
URL: https://github.com/apache/arrow/pull/12215#discussion_r812015264
##########
File path: cpp/src/arrow/compute/kernels/codegen_internal_test.cc
##########
@@ -202,6 +202,8 @@ TEST(TestDispatchBest, CommonTemporalResolution) {
ASSERT_EQ(TimeUnit::MILLI, CommonTemporalResolution(args.data(), args.size()));
args = {time64(TimeUnit::MICRO), duration(TimeUnit::NANO)};
ASSERT_EQ(TimeUnit::NANO, CommonTemporalResolution(args.data(), args.size()));
+ args = {duration(TimeUnit::SECOND), int64()};
+ ASSERT_EQ(TimeUnit::SECOND, CommonTemporalResolution(args.data(), args.size()));
Review comment:
I think this is fine, but maybe we need a better name for what this function does.
That said, I don't think this change is needed for this function to work, anyways. There's only a single temporal argument so there isn't really a meaningful common resolution to cast to.
##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -2802,23 +2802,55 @@ void RegisterScalarArithmetic(FunctionRegistry* registry) {
// ----------------------------------------------------------------------
auto multiply = MakeArithmeticFunction<Multiply>("multiply", &mul_doc);
AddDecimalBinaryKernels<Multiply>("multiply", multiply.get());
+
+ // Add multiply(duration, int64) -> duration
+ for (auto unit : TimeUnit::values()) {
+ auto exec = ArithmeticExecFromOp<ScalarBinaryEqualTypes, Multiply>(Type::DURATION);
+ DCHECK_OK(
+ multiply->AddKernel({duration(unit), int64()}, duration(unit), std::move(exec)));
Review comment:
Hmm, I don't see why not. It could just use the same exec function.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org