superdiaodiao commented on code in PR #41008: URL: https://github.com/apache/doris/pull/41008#discussion_r1766686407
########## be/src/vec/runtime/time_value.h: ########## @@ -22,17 +22,47 @@ #include "runtime/define_primitive_type.h" #include "runtime/primitive_type.h" #include "util/date_func.h" +#include "vec/data_types/data_type_time.h" namespace doris { /// TODO: Due to the "Time type is not supported for OLAP table" issue, a lot of basic content is missing.It will be supplemented later. class TimeValue { +public: + constexpr static int64_t ONE_SECOND_MICROSECONDS = 1000000; + constexpr static int64_t ONE_MINUTE_MICROSECONDS = 60 * ONE_SECOND_MICROSECONDS; + constexpr static int64_t ONE_HOUR_MICROSECONDS = 60 * ONE_MINUTE_MICROSECONDS; + constexpr static int64_t ONE_MINUTE_SECONDS = 60; + constexpr static int64_t ONE_HOUR_SECONDS = 60 * ONE_MINUTE_SECONDS; + using TimeType = typename PrimitiveTypeTraits<TYPE_TIMEV2>::CppType; + using ColumnTime = vectorized::DataTypeTimeV2::ColumnType; + + // refer to https://dev.mysql.com/doc/refman/5.7/en/time.html + // the time value between '-838:59:59' and '838:59:59' + /// TODO: Why is the time type stored as double? Can we directly use int64 and remove the time limit? + static int64_t check_over_max_time(double time) { + const static int64_t max_time = 3020399LL * 1000 * 1000; + if (time > max_time) { + return max_time; + } else if (time < -max_time) { + return max_time; + } Review Comment: The second return should be `-max_time`? If not, we could merge two conditions. -- 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