HappenLee commented on code in PR #56945:
URL: https://github.com/apache/doris/pull/56945#discussion_r2464001431
##########
be/src/vec/functions/function_date_or_datetime_computation.h:
##########
@@ -1378,5 +1379,94 @@ class FunctionGetFormat : public IFunction {
static constexpr auto TIME_NAME = "TIME";
};
+class PeriodHelper {
+public:
+ // For two digit year, 70-99 -> 1970-1999, 00-69 -> 2000-2069
+ // this rule is same as MySQL
+ static constexpr int YY_PART_YEAR = 70;
+ static Status valid_period(int64_t period) {
+ if (period <= 0 || (period % 100) == 0 || (period % 100) > 12) {
+ return Status::InvalidArgument("Period function got invalid
period: {}", period);
+ }
+ return Status::OK();
+ }
+
+ static int64_t check_and_convert_period_to_month(uint64_t period) {
+ THROW_IF_ERROR(valid_period(period));
+ uint64_t year = period / 100;
+ if (year < 100) {
+ year += (year >= YY_PART_YEAR) ? 1900 : 2000;
+ }
+ return year * 12LL + (period % 100) - 1;
Review Comment:
why here need to sub 1 and next func to do add 1. seems the 1 is unless?
--
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]