[Enhancement](Nereids)add datelikev2 type support for fold constant. #18275
add datelikev2 type support for fold constant. date_add / years_add / mouths_add / days_add / hours_add / minutes_add / seconds_add and xxx_sub.
This commit is contained in:
@ -592,18 +592,13 @@ public class ExecutableFunctions {
|
||||
t1.getPrecision(), t1.getScale() - t2.getScale()), result);
|
||||
}
|
||||
|
||||
@ExecFunction(name = "date_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral dateSub(DateTimeLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return dateAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "date_sub", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral dateSub(DateLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return dateAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "date_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal dateSub(DateTimeV2Literal date, IntegerLiteral day) throws AnalysisException {
|
||||
@ExecFunction(name = "date_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral dateSub(DateTimeLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return dateAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ -612,9 +607,9 @@ public class ExecutableFunctions {
|
||||
return dateAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "date_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral dateAdd(DateTimeLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return daysAdd(date, day);
|
||||
@ExecFunction(name = "date_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal dateSub(DateTimeV2Literal date, IntegerLiteral day) throws AnalysisException {
|
||||
return dateAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "date_add", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
@ -622,8 +617,8 @@ public class ExecutableFunctions {
|
||||
return daysAdd(date, day);
|
||||
}
|
||||
|
||||
@ExecFunction(name = "date_add", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal dateAdd(DateTimeV2Literal date, IntegerLiteral day) throws AnalysisException {
|
||||
@ExecFunction(name = "date_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral dateAdd(DateTimeLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return daysAdd(date, day);
|
||||
}
|
||||
|
||||
@ -632,9 +627,9 @@ public class ExecutableFunctions {
|
||||
return daysAdd(date, day);
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral yearsAdd(DateTimeLiteral date, IntegerLiteral year) throws AnalysisException {
|
||||
return date.plusYears(year.getValue());
|
||||
@ExecFunction(name = "date_add", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal dateAdd(DateTimeV2Literal date, IntegerLiteral day) throws AnalysisException {
|
||||
return daysAdd(date, day);
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_add", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
@ -642,8 +637,8 @@ public class ExecutableFunctions {
|
||||
return date.plusYears(year.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_add", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal yearsAdd(DateTimeV2Literal date, IntegerLiteral year) throws AnalysisException {
|
||||
@ExecFunction(name = "years_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral yearsAdd(DateTimeLiteral date, IntegerLiteral year) throws AnalysisException {
|
||||
return date.plusYears(year.getValue());
|
||||
}
|
||||
|
||||
@ -652,13 +647,23 @@ public class ExecutableFunctions {
|
||||
return date.plusYears(year.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_add", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal yearsAdd(DateTimeV2Literal date, IntegerLiteral year) throws AnalysisException {
|
||||
return date.plusYears(year.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_add", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral monthsAdd(DateLiteral date, IntegerLiteral month) throws AnalysisException {
|
||||
return date.plusMonths(month.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral monthsAdd(DateTimeLiteral date, IntegerLiteral month) throws AnalysisException {
|
||||
return date.plusMonths(month.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_add", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral monthsAdd(DateLiteral date, IntegerLiteral month) throws AnalysisException {
|
||||
@ExecFunction(name = "months_add", argTypes = { "DATEV2", "INT" }, returnType = "DATEV2")
|
||||
public static DateV2Literal monthsAdd(DateV2Literal date, IntegerLiteral month) throws AnalysisException {
|
||||
return date.plusMonths(month.getValue());
|
||||
}
|
||||
|
||||
@ -667,9 +672,9 @@ public class ExecutableFunctions {
|
||||
return date.plusMonths(month.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_add", argTypes = { "DATEV2", "INT" }, returnType = "DATEV2")
|
||||
public static DateV2Literal monthsAdd(DateV2Literal date, IntegerLiteral month) throws AnalysisException {
|
||||
return date.plusMonths(month.getValue());
|
||||
@ExecFunction(name = "days_add", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral daysAdd(DateLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return date.plusDays(day.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "days_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
@ -687,54 +692,123 @@ public class ExecutableFunctions {
|
||||
return date.plusDays(day.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "days_add", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral daysAdd(DateLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return date.plusDays(day.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "hours_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral hoursAdd(DateTimeLiteral date, IntegerLiteral hour) throws AnalysisException {
|
||||
return date.plusHours(hour.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "hours_add", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal hoursAdd(DateTimeV2Literal date, IntegerLiteral hour) throws AnalysisException {
|
||||
return date.plusHours(hour.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "minutes_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral minutesAdd(DateTimeLiteral date, IntegerLiteral minute) throws AnalysisException {
|
||||
return date.plusMinutes(minute.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "minutes_add", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal minutesAdd(DateTimeV2Literal date, IntegerLiteral minute) throws AnalysisException {
|
||||
return date.plusMinutes(minute.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "seconds_add", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral secondsAdd(DateTimeLiteral date, IntegerLiteral second) throws AnalysisException {
|
||||
return date.plusSeconds(second.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "seconds_add", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal secondsAdd(DateTimeV2Literal date, IntegerLiteral second) throws AnalysisException {
|
||||
return date.plusSeconds(second.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_sub", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral yearsSub(DateLiteral date, IntegerLiteral year) throws AnalysisException {
|
||||
return yearsAdd(date, new IntegerLiteral(-year.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral yearsSub(DateTimeLiteral date, IntegerLiteral year) throws AnalysisException {
|
||||
return yearsAdd(date, new IntegerLiteral(-year.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_sub", argTypes = { "DATEV2", "INT" }, returnType = "DATEV2")
|
||||
public static DateV2Literal yearsSub(DateV2Literal date, IntegerLiteral year) throws AnalysisException {
|
||||
return yearsAdd(date, new IntegerLiteral(-year.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "years_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal yearsSub(DateTimeV2Literal date, IntegerLiteral year) throws AnalysisException {
|
||||
return yearsAdd(date, new IntegerLiteral(-year.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_sub", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral monthsSub(DateLiteral date, IntegerLiteral month) throws AnalysisException {
|
||||
return monthsAdd(date, new IntegerLiteral(-month.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral monthsSub(DateTimeLiteral date, IntegerLiteral month) throws AnalysisException {
|
||||
return monthsAdd(date, new IntegerLiteral(-month.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_sub", argTypes = { "DATEV2", "INT" }, returnType = "DATEV2")
|
||||
public static DateV2Literal monthsSub(DateV2Literal date, IntegerLiteral month) throws AnalysisException {
|
||||
return monthsAdd(date, new IntegerLiteral(-month.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "months_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal monthsSub(DateTimeV2Literal date, IntegerLiteral month) throws AnalysisException {
|
||||
return monthsAdd(date, new IntegerLiteral(-month.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "days_sub", argTypes = { "DATE", "INT" }, returnType = "DATE")
|
||||
public static DateLiteral daysSub(DateLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return daysAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "days_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral daysSub(DateTimeLiteral date, IntegerLiteral day) throws AnalysisException {
|
||||
return daysAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "days_sub", argTypes = { "DATEV2", "INT" }, returnType = "DATEV2")
|
||||
public static DateV2Literal daysSub(DateV2Literal date, IntegerLiteral day) throws AnalysisException {
|
||||
return daysAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "days_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal daysSub(DateTimeV2Literal date, IntegerLiteral day) throws AnalysisException {
|
||||
return daysAdd(date, new IntegerLiteral(-day.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "hours_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral hoursSub(DateTimeLiteral date, IntegerLiteral hour) throws AnalysisException {
|
||||
return hoursAdd(date, new IntegerLiteral(-hour.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "hours_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal hoursSub(DateTimeV2Literal date, IntegerLiteral hour) throws AnalysisException {
|
||||
return hoursAdd(date, new IntegerLiteral(-hour.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "minutes_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral minutesSub(DateTimeLiteral date, IntegerLiteral minute) throws AnalysisException {
|
||||
return minutesAdd(date, new IntegerLiteral(-minute.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "minutes_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal minutesSub(DateTimeV2Literal date, IntegerLiteral minute) throws AnalysisException {
|
||||
return minutesAdd(date, new IntegerLiteral(-minute.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "seconds_sub", argTypes = { "DATETIME", "INT" }, returnType = "DATETIME")
|
||||
public static DateTimeLiteral secondsSub(DateTimeLiteral date, IntegerLiteral second) throws AnalysisException {
|
||||
return secondsAdd(date, new IntegerLiteral(-second.getValue()));
|
||||
}
|
||||
|
||||
@ExecFunction(name = "seconds_sub", argTypes = { "DATETIMEV2", "INT" }, returnType = "DATETIMEV2")
|
||||
public static DateTimeV2Literal secondsSub(DateTimeV2Literal date, IntegerLiteral second) throws AnalysisException {
|
||||
return secondsAdd(date, new IntegerLiteral(-second.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user