yiguolei commented on code in PR #65823:
URL: https://github.com/apache/doris/pull/65823#discussion_r3626783923


##########
be/src/core/data_type_serde/data_type_datetimev2_serde.cpp:
##########
@@ -493,57 +488,40 @@ Status 
DataTypeDateTimeV2SerDe::read_column_from_arrow(IColumn& column,
         check_arrow_no_offset(*arrow_array);
     }
     auto& col_data = static_cast<ColumnDateTimeV2&>(column).get_data();
-    int64_t divisor = 1;
     if (arrow_array->type()->id() == arrow::Type::TIMESTAMP) {
         const auto* concrete_array = dynamic_cast<const 
arrow::TimestampArray*>(arrow_array);
         const auto type = 
std::static_pointer_cast<arrow::TimestampType>(arrow_array->type());
-        switch (type->unit()) {
-        case arrow::TimeUnit::type::SECOND: {
-            divisor = DIVISOR_FOR_SECOND;
-            break;
-        }
-        case arrow::TimeUnit::type::MILLI: {
-            divisor = DIVISOR_FOR_MILLI;
-            break;
-        }
-        case arrow::TimeUnit::type::MICRO: {
-            divisor = DIVISOR_FOR_MICRO;
-            break;
-        }
-        case arrow::TimeUnit::type::NANO: {
-            divisor = DIVISOR_FOR_NANO;
-            break;
-        }
-        default: {
-            LOG(WARNING) << "not support convert to datetimev2 from 
time_unit:" << type->unit();
-            return Status::InvalidArgument("not support convert to datetimev2 
from time_unit: {}",
-                                           type->unit());
-        }
-        }
         const auto* base_ptr = reinterpret_cast<const 
uint8_t*>(concrete_array->raw_values());
         const size_t element_size = sizeof(int64_t);
         for (auto value_i = start; value_i < end; ++value_i) {
             const uint8_t* raw_byte_ptr = base_ptr + value_i * element_size;
             auto date_value = unaligned_load<int64_t>(raw_byte_ptr);
-
-            DateV2Value<DateTimeV2ValueType> v;
-            // C++ integer division truncates toward zero. Normalize the 
remainder so a negative
-            // timestamp still has a non-negative fractional part, e.g. 
-876544us becomes
-            // -1 second and 123456us.
-            int64_t seconds = date_value / divisor;
-            int64_t remainder = date_value % divisor;
-            if (remainder < 0) {
-                --seconds;
-                remainder += divisor;
+            int64_t timestamp_micros;
+            switch (type->unit()) {
+            case arrow::TimeUnit::type::SECOND:
+                timestamp_micros = date_value * 1000000;
+                break;
+            case arrow::TimeUnit::type::MILLI:
+                timestamp_micros = date_value * 1000;
+                break;
+            case arrow::TimeUnit::type::MICRO:
+                timestamp_micros = date_value;
+                break;
+            case arrow::TimeUnit::type::NANO:
+                timestamp_micros = date_value / 1000;
+                if (date_value % 1000 < 0) {
+                    --timestamp_micros;
+                }
+                break;
+            default:
+                return Status::InvalidArgument(
+                        "not support convert to datetimev2 from time_unit: 
{}", type->unit());
+            }
+            if (type->timezone().empty()) {

Review Comment:
   得ut 覆盖这2段逻辑



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to