You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/06/07 08:57:24 UTC
[incubator-doris] 02/06: [Bug] Fix timestamp_diff issue when timeunit is year and month (#9574)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit ed04506425139151f760a1871596f6ff336b6c6e
Author: huangzhaowei <ca...@gmail.com>
AuthorDate: Thu May 19 21:24:43 2022 +0800
[Bug] Fix timestamp_diff issue when timeunit is year and month (#9574)
---
be/src/runtime/datetime_value.h | 14 ++++++++------
be/src/vec/runtime/vdatetime_value.h | 14 ++++++++------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/be/src/runtime/datetime_value.h b/be/src/runtime/datetime_value.h
index 4f3a310e48..b4c7c58638 100644
--- a/be/src/runtime/datetime_value.h
+++ b/be/src/runtime/datetime_value.h
@@ -288,11 +288,11 @@ public:
case YEAR: {
int year = (ts_value2.year() - ts_value1.year());
if (year > 0) {
- year -= (ts_value2.to_int64() % 10000000000 - ts_value1.to_int64() % 10000000000) <
- 0;
+ year -= (ts_value2.to_datetime_int64() % 10000000000 -
+ ts_value1.to_datetime_int64() % 10000000000) < 0;
} else if (year < 0) {
- year += (ts_value2.to_int64() % 10000000000 - ts_value1.to_int64() % 10000000000) >
- 0;
+ year += (ts_value2.to_datetime_int64() % 10000000000 -
+ ts_value1.to_datetime_int64() % 10000000000) > 0;
}
return year;
}
@@ -300,9 +300,11 @@ public:
int month = (ts_value2.year() - ts_value1.year()) * 12 +
(ts_value2.month() - ts_value1.month());
if (month > 0) {
- month -= (ts_value2.to_int64() % 100000000 - ts_value1.to_int64() % 100000000) < 0;
+ month -= (ts_value2.to_datetime_int64() % 100000000 -
+ ts_value1.to_datetime_int64() % 100000000) < 0;
} else if (month < 0) {
- month += (ts_value2.to_int64() % 100000000 - ts_value1.to_int64() % 100000000) > 0;
+ month += (ts_value2.to_datetime_int64() % 100000000 -
+ ts_value1.to_datetime_int64() % 100000000) > 0;
}
return month;
}
diff --git a/be/src/vec/runtime/vdatetime_value.h b/be/src/vec/runtime/vdatetime_value.h
index a51be2e41f..99a6dee5c6 100644
--- a/be/src/vec/runtime/vdatetime_value.h
+++ b/be/src/vec/runtime/vdatetime_value.h
@@ -288,11 +288,11 @@ public:
case YEAR: {
int year = (ts_value2.year() - ts_value1.year());
if (year > 0) {
- year -= (ts_value2.to_int64() % 10000000000 - ts_value1.to_int64() % 10000000000) <
- 0;
+ year -= (ts_value2.to_datetime_int64() % 10000000000 -
+ ts_value1.to_datetime_int64() % 10000000000) < 0;
} else if (year < 0) {
- year += (ts_value2.to_int64() % 10000000000 - ts_value1.to_int64() % 10000000000) >
- 0;
+ year += (ts_value2.to_datetime_int64() % 10000000000 -
+ ts_value1.to_datetime_int64() % 10000000000) > 0;
}
return year;
}
@@ -300,9 +300,11 @@ public:
int month = (ts_value2.year() - ts_value1.year()) * 12 +
(ts_value2.month() - ts_value1.month());
if (month > 0) {
- month -= (ts_value2.to_int64() % 100000000 - ts_value1.to_int64() % 100000000) < 0;
+ month -= (ts_value2.to_datetime_int64() % 100000000 -
+ ts_value1.to_datetime_int64() % 100000000) < 0;
} else if (month < 0) {
- month += (ts_value2.to_int64() % 100000000 - ts_value1.to_int64() % 100000000) > 0;
+ month += (ts_value2.to_datetime_int64() % 100000000 -
+ ts_value1.to_datetime_int64() % 100000000) > 0;
}
return month;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org