SaintBacchus commented on code in PR #16633:
URL: https://github.com/apache/doris/pull/16633#discussion_r1105313944


##########
be/src/exec/es/es_scroll_parser.cpp:
##########
@@ -528,72 +530,104 @@ Status ScrollParser::fill_columns(const TupleDescriptor* 
tuple_desc,
     return Status::OK();
 }
 
-Status ScrollParser::fill_date_slot_with_strval(void* slot, const 
rapidjson::Value& col,
-                                                PrimitiveType type) {
-    DateTimeValue* ts_slot = reinterpret_cast<DateTimeValue*>(slot);
-    const std::string& val = col.GetString();
-    size_t val_size = col.GetStringLength();
-    if (!ts_slot->from_date_str(val.c_str(), val_size)) {
-        RETURN_ERROR_IF_CAST_FORMAT_ERROR(col, type);
-    }
-    if (type == TYPE_DATE) {
-        ts_slot->cast_to_date();
-    } else {
-        ts_slot->to_datetime();
-    }
-    return Status::OK();
-}
-
-Status ScrollParser::fill_date_slot_with_timestamp(void* slot, const 
rapidjson::Value& col,
-                                                   PrimitiveType type) {
-    if (!reinterpret_cast<DateTimeValue*>(slot)->from_unixtime(col.GetInt64() 
/ 1000, "+08:00")) {
-        RETURN_ERROR_IF_CAST_FORMAT_ERROR(col, type);
-    }
-    if (type == TYPE_DATE) {
-        reinterpret_cast<DateTimeValue*>(slot)->cast_to_date();
-    } else {
-        reinterpret_cast<DateTimeValue*>(slot)->set_type(TIME_DATETIME);
-    }
-    return Status::OK();
-}
-
 Status ScrollParser::fill_date_col_with_strval(vectorized::IColumn* col_ptr,
                                                const rapidjson::Value& col, 
PrimitiveType type) {
-    vectorized::VecDateTimeValue dt_val;
     const std::string& val = col.GetString();
     size_t val_size = col.GetStringLength();
-    if (!dt_val.from_date_str(val.c_str(), val_size)) {
-        RETURN_ERROR_IF_CAST_FORMAT_ERROR(col, type);
-    }
-    if (type == TYPE_DATE) {
-        dt_val.cast_to_date();
+
+    if (type == TYPE_DATE || type == TYPE_DATETIME) {
+        vectorized::VecDateTimeValue dt_val;
+        if (!dt_val.from_date_str(val.c_str(), val_size)) {
+            RETURN_ERROR_IF_CAST_FORMAT_ERROR(col, type);
+        }
+        if (type == TYPE_DATE) {
+            dt_val.cast_to_date();
+        } else {
+            dt_val.to_datetime();
+        }
+
+        auto date_packed_int = 
binary_cast<doris::vectorized::VecDateTimeValue, int64_t>(
+                *reinterpret_cast<vectorized::VecDateTimeValue*>(&dt_val));
+        col_ptr->insert_data(const_cast<const 
char*>(reinterpret_cast<char*>(&date_packed_int)), 0);
+        return Status::OK();

Review Comment:
   date_packed_int is different type



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