xxlaykxx commented on code in PR #55864:
URL: https://github.com/apache/arrow/pull/55864#discussion_r4770417746


##########
cpp/src/arrow/flight/sql/odbc/odbc_impl/util.cc:
##########
@@ -906,6 +907,42 @@ std::shared_ptr<Array> CheckConversion(const 
arrow::Result<Datum>& result) {
   }
 }
 
+namespace {
+int64_t UnitsPerSecond(TimeUnit::type unit) {
+  switch (unit) {
+    case TimeUnit::SECOND:
+      return 1;
+    case TimeUnit::MILLI:
+      return 1000;
+    case TimeUnit::MICRO:
+      return 1000000;
+    case TimeUnit::NANO:
+      return 1000000000;
+  }
+  throw DriverException("Unrecognized time unit");
+}
+
+// Converts a time32/time64 array to a timestamp array of the same unit, 
holding
+// today's date plus the time of day.
+std::shared_ptr<Array> ConvertTimeToTodayTimestamp(
+    const std::shared_ptr<Array>& original_array) {
+  const auto unit =
+      arrow::internal::checked_cast<const 
TimeType&>(*original_array->type()).unit();
+
+  std::shared_ptr<Array> as_int = original_array;
+  if (original_array->type_id() == Type::TIME32) {
+    as_int = CheckConversion(arrow::compute::Cast(as_int, arrow::int32()));

Review Comment:
   Unfortunately not — there's no `time32 -> int64` cast kernel. `cast_int64` 
only registers zero-copy casts from `date64`, `duration`, `timestamp` and 
`time64`, while `time32` is registered only on `cast_int32` (see 
`scalar_cast_numeric.cc`), so a direct cast fails with a "not implemented" 
error. Going through `int32` first is zero-copy, so the extra step only costs 
the widening to `int64` that we need anyway for the add. The previous code did 
the same two-step cast for this reason. I can add a short comment there if you 
think it helps.



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