rok commented on a change in pull request #10647:
URL: https://github.com/apache/arrow/pull/10647#discussion_r678369688



##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal.cc
##########
@@ -470,6 +536,41 @@ std::shared_ptr<ScalarFunction> MakeTemporalWithOptions(
   return func;
 }
 
+std::shared_ptr<ScalarFunction> MakeStrftime(std::string name, const 
FunctionDoc* doc,
+                                             const StrftimeOptions& 
default_options,
+                                             KernelInit init) {
+  const auto& out_type = utf8();
+  auto func =
+      std::make_shared<ScalarFunction>(name, Arity::Unary(), doc, 
&default_options);
+
+  for (auto unit : internal::AllTimeUnits()) {
+    InputType in_type{match::TimestampTypeUnit(unit)};
+    switch (unit) {
+      case TimeUnit::SECOND: {
+        auto exec = SimpleUnary<Strftime<std::chrono::seconds>>;
+        DCHECK_OK(func->AddKernel({in_type}, out_type, std::move(exec), init));
+        break;
+      }
+      case TimeUnit::MILLI: {
+        auto exec = SimpleUnary<Strftime<std::chrono::milliseconds>>;
+        DCHECK_OK(func->AddKernel({in_type}, out_type, std::move(exec), init));
+        break;
+      }
+      case TimeUnit::MICRO: {
+        auto exec = SimpleUnary<Strftime<std::chrono::microseconds>>;
+        DCHECK_OK(func->AddKernel({in_type}, out_type, std::move(exec), init));
+        break;
+      }
+      case TimeUnit::NANO: {
+        auto exec = SimpleUnary<Strftime<std::chrono::nanoseconds>>;
+        DCHECK_OK(func->AddKernel({in_type}, out_type, std::move(exec), init));
+        break;
+      }
+    }

Review comment:
       Ok, I'll give it a spin.




-- 
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]


Reply via email to