Gabriel39 commented on code in PR #67784:
URL: https://github.com/apache/doris/pull/67784#discussion_r3986560367


##########
be/src/core/data_type_serde/data_type_serde.cpp:
##########
@@ -496,8 +524,28 @@ Status decode_timestamp_orc_values(IColumn& nested_column, 
const OrcDecodedColum
         }
         auto& value =
                 
reinterpret_cast<DateV2Value<DateTimeV2ValueType>&>(data[old_data_size + row]);
+        RoundedOrcTimestamp timestamp;
+        auto status = round_orc_timestamp_to_microseconds(
+                orc_batch->data[source_row], 
orc_batch->nanoseconds[source_row], &timestamp);
+        if (!status.ok()) {
+            data.resize(old_data_size);
+            return status;
+        }
         value.from_unixtime(orc_batch->data[source_row], timezone);
-        
value.set_microsecond(cast_set<uint64_t>(orc_batch->nanoseconds[source_row] / 
1000));
+        if (!value.is_valid_date()) {

Review Comment:
   Fixed in db858711d3. TIMESTAMP_INSTANT now converts the effective rounded 
epoch second, and a new test covers rounding from -62167219201.999999500 into 
the supported year-zero boundary.



##########
be/src/core/data_type_serde/data_type_serde.cpp:
##########
@@ -477,6 +477,34 @@ int64_t find_struct_child_index(const ::orc::Type& type, 
const std::string& fiel
     return -1;
 }
 
+struct RoundedOrcTimestamp {
+    int64_t seconds;
+    uint64_t microseconds;
+    bool carry;
+};
+
+Status round_orc_timestamp_to_microseconds(int64_t seconds, int64_t 
nanoseconds,
+                                           RoundedOrcTimestamp* result) {
+    constexpr int64_t NANOS_PER_SECOND = 1000000000;
+    constexpr int64_t NANOS_PER_MICROSECOND = 1000;
+    constexpr int64_t MICROS_PER_SECOND = 1000000;
+    DORIS_CHECK(result != nullptr);
+    DORIS_CHECK(nanoseconds >= 0 && nanoseconds < NANOS_PER_SECOND);

Review Comment:
   Fixed in db858711d3. Invalid ORC nanoseconds now return DataQualityError 
through the existing Status path instead of triggering DORIS_CHECK. Added 
coverage for negative and one-billion nanosecond values.



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