zclllyybb commented on code in PR #55136:
URL: https://github.com/apache/doris/pull/55136#discussion_r2312552811


##########
be/src/vec/functions/function_datetime_floor_ceil.cpp:
##########
@@ -110,6 +110,28 @@ class FunctionDateTimeFloorCeil : public IFunction {
 
     bool is_variadic() const override { return true; }
 
+    static void throw_if_illegal_period(NativeType date, Int32 period) {
+        auto date_value = binary_cast<NativeType, DateValueType>(date);
+        char buf[40];
+        char* end = date_value.to_string(buf);
+        if (period < 1) [[unlikely]] {
+            throw Exception(ErrorCode::INVALID_ARGUMENT,
+                            "Operation {} of {}, {} input wrong parameters, 
period can`t be "
+                            "negative or zero",
+                            name, std::string_view {buf, end - 1}, period);
+        }
+    }
+
+    static void throw_if_out_bound(NativeType date, bool in_bound, Int32 
period = 1) {
+        auto date_value = binary_cast<NativeType, DateValueType>(date);
+        char buf[40];
+        char* end = date_value.to_string(buf);
+        if (!in_bound) {

Review Comment:
   unlikely



##########
be/src/vec/functions/function_date_or_datetime_computation.h:
##########
@@ -951,15 +965,14 @@ struct TimestampToDateTime : IFunction {
         res_col->get_data().resize_fill(input_rows_count, 0);
         null_vector->get_data().resize_fill(input_rows_count, false);
 
-        NullMap& null_map = null_vector->get_data();
         auto& res_data = res_col->get_data();
         const cctz::time_zone& time_zone = context->state()->timezone_obj();
 
         for (int i = 0; i < input_rows_count; ++i) {
             Int64 value = column_data.get_element(i);
             if (value < 0) {
-                null_map[i] = true;
-                continue;
+                return Status::InternalError("The function {} Argument value 
must be non-negative",

Review Comment:
   not internal error. should be invalid argument here



##########
be/src/vec/functions/date_time_transforms.h:
##########
@@ -370,23 +376,29 @@ struct FromUnixTimeDecimalImpl {
         return dt;
     }
 
-    // return true if null(result is invalid)
+    // throw exception if invalid (instead of returning true for null)
     template <typename Impl>
     static bool execute_decimal(const ArgType& interger, const ArgType& 
fraction, StringRef format,
                                 ColumnString::Chars& res_data, size_t& offset,
                                 const cctz::time_zone& time_zone) {
         if (!check_valid(interger + (fraction > 0 ? 1 : ((fraction < 0) ? -1 : 
0)))) {
-            return true;
+            throw Exception(ErrorCode::INVALID_ARGUMENT,
+                            "Timestamp value {} is out of supported range 
(must be non-negative)",
+                            interger + (fraction > 0 ? 1 : ((fraction < 0) ? 
-1 : 0)));
         }
         DateV2Value<DateTimeV2ValueType> dt = get_datetime_value(interger, 
fraction, time_zone);
         if (!dt.is_valid_date()) {
-            return true;
+            throw Exception(ErrorCode::OUT_OF_BOUND,

Review Comment:
   should be internal error



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