[Bug](function) fix current_date not equal to curdate (#11463)
* fix current_date not equal to curdate
This commit is contained in:
@ -278,6 +278,11 @@ void VecDateTimeValue::set_zero(int type) {
|
||||
|
||||
void VecDateTimeValue::set_type(int type) {
|
||||
_type = type;
|
||||
if (type == TIME_DATE) {
|
||||
_hour = 0;
|
||||
_minute = 0;
|
||||
_second = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void VecDateTimeValue::set_max_time(bool neg) {
|
||||
|
||||
@ -309,11 +309,13 @@ public class DateLiteral extends LiteralExpr {
|
||||
this.year = dateTime.getYear();
|
||||
this.month = dateTime.getMonthValue();
|
||||
this.day = dateTime.getDayOfMonth();
|
||||
this.hour = dateTime.getHour();
|
||||
this.minute = dateTime.getMinute();
|
||||
this.second = dateTime.getSecond();
|
||||
this.microsecond = dateTime.get(ChronoField.MICRO_OF_SECOND);
|
||||
this.type = type;
|
||||
if (type.equals(Type.DATETIME) || type.equals(Type.DATETIMEV2)) {
|
||||
this.hour = dateTime.getHour();
|
||||
this.minute = dateTime.getMinute();
|
||||
this.second = dateTime.getSecond();
|
||||
this.microsecond = dateTime.get(ChronoField.MICRO_OF_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
public DateLiteral(DateLiteral other) {
|
||||
|
||||
@ -745,7 +745,7 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
|
||||
try {
|
||||
return trySubstituteList(exprs, smap, analyzer, preserveRootTypes);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Failed analysis after expr substitution.", e);
|
||||
throw new IllegalStateException("Failed analysis after expr substitution: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -341,3 +341,9 @@ February
|
||||
-- !sql --
|
||||
1 2022-08-01 17:00:31
|
||||
|
||||
-- !sql --
|
||||
true
|
||||
|
||||
-- !sql --
|
||||
true
|
||||
|
||||
|
||||
@ -286,5 +286,8 @@ suite("test_date_function", "query") {
|
||||
qt_sql """ SELECT id,FROM_UNIXTIME(update_time,"%Y-%m-%d %H:%i:%s") FROM ${tableName} WHERE FROM_UNIXTIME(update_time,"%Y-%m-%d %H:%i:%s") LIKE '2022-08-01 00:00:00' ORDER BY id; """
|
||||
qt_sql """ SELECT id,FROM_UNIXTIME(update_time,"%Y-%m-%d %H:%i:%s") FROM ${tableName} WHERE FROM_UNIXTIME(update_time,"%Y-%m-%d %H:%i:%s") = '2022-08-01 17:00:31' ORDER BY id; """
|
||||
|
||||
qt_sql """SELECT CURDATE() = CURRENT_DATE();"""
|
||||
qt_sql """SELECT unix_timestamp(CURDATE()) = unix_timestamp(CURRENT_DATE());"""
|
||||
|
||||
sql """ drop table ${tableName} """
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user