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/01 15:29:13 UTC

[incubator-doris] 18/22: [BUG] return NULL for invalid date value (#9862)

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 9f14de2127149d1cab53453cf98377ca6c386c1c
Author: Gabriel <ga...@gmail.com>
AuthorDate: Mon May 30 21:35:41 2022 +0800

    [BUG] return NULL for invalid date value (#9862)
---
 be/src/vec/runtime/vdatetime_value.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/be/src/vec/runtime/vdatetime_value.cpp b/be/src/vec/runtime/vdatetime_value.cpp
index ec40d27b00..97cec16e0f 100644
--- a/be/src/vec/runtime/vdatetime_value.cpp
+++ b/be/src/vec/runtime/vdatetime_value.cpp
@@ -61,11 +61,11 @@ bool VecDateTimeValue::check_range(uint32_t year, uint32_t month, uint32_t day,
 }
 
 bool VecDateTimeValue::check_date(uint32_t year, uint32_t month, uint32_t day) {
-    if (month != 0 && month <= 12 && day > s_days_in_month[month]) {
-        // Feb 29 in leap year is valid.
-        if (!(month == 2 && day == 29 && is_leap(year))) return true;
+    if (month == 2 && day == 29 && is_leap(year)) return false;
+    if (year > 9999 || month == 0 || month > 12 || day > s_days_in_month[month] || day == 0) {
+        return true;
     }
-    return year > 9999 || month > 12 || day > 31;
+    return false;
 }
 
 // The interval format is that with no delimiters


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org