morningman commented on code in PR #19436:
URL: https://github.com/apache/doris/pull/19436#discussion_r1190880127


##########
be/src/vec/runtime/vparquet_writer.cpp:
##########
@@ -469,26 +604,41 @@ Status VParquetWriterWrapper::write(const Block& block) {
                     for (size_t row_id = 0; row_id < sz; row_id++) {
                         def_level[row_id] = null_data[row_id] == 0;
                     }
-                    uint64_t tmp_data[sz];
+                    VecDateTimeValue epoch_date;
+                    if (!epoch_date.from_date_str(epoch_date_str.c_str(),
+                                                  epoch_date_str.length())) {
+                        return Status::InternalError("create epoch date from 
string error");
+                    }
+                    int32_t days_from_epoch = epoch_date.daynr();
+                    int32_t tmp_data[sz];
                     for (size_t row_id = 0; row_id < sz; row_id++) {
                         if (null_data[row_id] != 0) {
                             tmp_data[row_id] = default_int64;
                         } else {
-                            tmp_data[row_id] = binary_cast<Int64, 
VecDateTimeValue>(
-                                                       assert_cast<const 
ColumnVector<Int64>&>(*col)
-                                                               
.get_data()[row_id])
-                                                       .to_olap_datetime();
+                            int32_t days = binary_cast<Int64, 
VecDateTimeValue>(
+                                                   assert_cast<const 
ColumnVector<Int64>&>(*col)
+                                                           .get_data()[row_id])
+                                                   .daynr();
+                            tmp_data[row_id] = days - days_from_epoch;
                         }
                     }
                     col_writer->WriteBatch(sz, def_level.data(), nullptr,
                                            reinterpret_cast<const 
int64_t*>(tmp_data));
                 } else if (const auto* not_nullable_column =

Review Comment:
   `not_nullable_column` is unused, remove it.



##########
be/src/util/time_lut.cpp:
##########
@@ -112,8 +112,14 @@ uint32_t calc_daynr(uint16_t year, uint8_t month, uint8_t 
day) {
         // 0, 0, 3, 3, 4, 4, 5, 5, 5,  6,  7,  8
         delsum -= (month * 4 + 23) / 10;
     }
-    // Every 400 year has 97 leap year, 100, 200, 300 are not leap year.
-    return delsum + y / 4 - y / 100 + y / 400;
+    // 'y == -1' means year is 0000 and month <= 2
+    if (y == -1) {
+        return delsum;
+    }
+
+    // Every 400 year has 97 leap year, 100, 200, 300 are not leap year.\

Review Comment:
   ```suggestion
       // Every 400 year has 97 leap year, 100, 200, 300 are not leap year.
   ```
   Otherwise, it will compile fail: `be/src/util/time_lut.cpp:120:5: error: 
multi-line comment [-Werror=comment]`



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to