pitrou commented on a change in pull request #10457:
URL: https://github.com/apache/arrow/pull/10457#discussion_r689531944



##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal.cc
##########
@@ -63,79 +71,132 @@ const std::string& GetInputTimezone(const ArrayData& 
array) {
   return checked_cast<const TimestampType&>(*array.type).timezone();
 }
 
-template <typename T>
-Status TemporalComponentExtractCheckTimezone(const T& input) {
-  const auto& timezone = GetInputTimezone(input);
-  if (!timezone.empty()) {
-    return Status::NotImplemented(
-        "Cannot extract components from timestamp with specific timezone: ", 
timezone);
-  }
-  return Status::OK();
-}
-
-template <typename Op, typename OutType>
+template <
+    template <typename Duration, typename TimePointConverter, typename 
DaysConverter>
+    class Op,
+    typename Duration, typename OutType>
 struct TemporalComponentExtract {
-  using OutValue = typename internal::GetOutputType<OutType>::T;
-
   static Status Exec(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
-    RETURN_NOT_OK(TemporalComponentExtractCheckTimezone(batch.values[0]));
-    return ScalarUnaryNotNull<OutType, TimestampType, Op>::Exec(ctx, batch, 
out);
+    const auto& timezone = GetInputTimezone(batch.values[0]);
+    if (timezone.empty()) {
+      using ExecTemplate = Op<Duration, 
std::function<sys_time<Duration>(int64_t)>,
+                              std::function<sys_days(sys_days)>>;
+      auto op = ExecTemplate([](int64_t t) { return 
sys_time<Duration>(Duration{t}); },
+                             [](sys_days d) { return d; });

Review comment:
       Can probably avoid the overhead of `std::function` by templating with 
the callable type itself.




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