[feature](nereids) Date add and Date sub related functions (#14753)
## date_add series - DATE_ADD - DAYS_ADD - ADDDATE - TIMESTAMPADD ## date_sub series - DATE_SUB - DAYS_SUB - SUBDATE ## NOTE 1. For DAYS_XXX, time unit is omissible, by default the time unit is DAY 2. no TIMESTAMPSUB
This commit is contained in:
@ -90,6 +90,7 @@ RIGHT_BRACKET: ']';
|
||||
//============================
|
||||
//--DORIS-KEYWORD-LIST-START
|
||||
ADD: 'ADD';
|
||||
ADDDATE:'ADDDATE';
|
||||
AFTER: 'AFTER';
|
||||
ALL: 'ALL';
|
||||
ALTER: 'ALTER';
|
||||
@ -143,13 +144,16 @@ CURRENT_TIME: 'CURRENT_TIME';
|
||||
CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
|
||||
CURRENT_USER: 'CURRENT_USER';
|
||||
DAY: 'DAY';
|
||||
DAYS_ADD: 'DAYS_ADD';
|
||||
DAYS_SUB: 'DAYS_SUB';
|
||||
DATA: 'DATA';
|
||||
DATABASE: 'DATABASE';
|
||||
DATABASES: 'DATABASES';
|
||||
DATE: 'DATE';
|
||||
DATEADD: 'DATEADD';
|
||||
DATE_ADD: 'DATE_ADD';
|
||||
DATEDIFF: 'DATEDIFF';
|
||||
DATE_ADD: 'DATE_ADD';
|
||||
DATE_SUB: 'DATE_SUB';
|
||||
DATE_DIFF: 'DATE_DIFF';
|
||||
DBPROPERTIES: 'DBPROPERTIES';
|
||||
DEFINED: 'DEFINED';
|
||||
@ -328,6 +332,7 @@ STATISTICS: 'STATISTICS';
|
||||
STORED: 'STORED';
|
||||
STRATIFY: 'STRATIFY';
|
||||
STRUCT: 'STRUCT';
|
||||
SUBDATE: 'SUBDATE';
|
||||
SUBSTR: 'SUBSTR';
|
||||
SUBSTRING: 'SUBSTRING';
|
||||
SUM: 'SUM';
|
||||
|
||||
@ -275,6 +275,18 @@ primaryExpression
|
||||
startTimestamp=valueExpression COMMA
|
||||
endTimestamp=valueExpression
|
||||
RIGHT_PAREN #timestampdiff
|
||||
| name=(TIMESTAMPADD | ADDDATE | DAYS_ADD | DATE_ADD)
|
||||
LEFT_PAREN
|
||||
timestamp=valueExpression COMMA
|
||||
(INTERVAL unitsAmount=valueExpression unit=datetimeUnit
|
||||
| unitsAmount=valueExpression)
|
||||
RIGHT_PAREN #date_add
|
||||
| name=(SUBDATE | DAYS_SUB | DATE_SUB)
|
||||
LEFT_PAREN
|
||||
timestamp=valueExpression COMMA
|
||||
(INTERVAL unitsAmount=valueExpression unit=datetimeUnit
|
||||
| unitsAmount=valueExpression)
|
||||
RIGHT_PAREN #date_sub
|
||||
| CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase
|
||||
| CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase
|
||||
| name=CAST LEFT_PAREN expression AS identifier RIGHT_PAREN #cast
|
||||
@ -371,6 +383,7 @@ number
|
||||
ansiNonReserved
|
||||
//--ANSI-NON-RESERVED-START
|
||||
: ADD
|
||||
| ADDDATE
|
||||
| AFTER
|
||||
| ALTER
|
||||
| ANALYZE
|
||||
@ -409,11 +422,14 @@ ansiNonReserved
|
||||
| DATABASE
|
||||
| DATABASES
|
||||
| DATE
|
||||
| DATEADD
|
||||
| DATE_ADD
|
||||
| DATEDIFF
|
||||
| DATE_DIFF
|
||||
| DAY
|
||||
| DAYS_ADD
|
||||
| DAYS_SUB
|
||||
| DATE_ADD
|
||||
| DATE_SUB
|
||||
| DBPROPERTIES
|
||||
| DEFINED
|
||||
| DELETE
|
||||
@ -545,6 +561,7 @@ ansiNonReserved
|
||||
| STORED
|
||||
| STRATIFY
|
||||
| STRUCT
|
||||
| SUBDATE
|
||||
| SUBSTR
|
||||
| SUBSTRING
|
||||
| SUM
|
||||
@ -670,7 +687,6 @@ nonReserved
|
||||
| DATABASE
|
||||
| DATABASES
|
||||
| DATE
|
||||
| DATEADD
|
||||
| DATE_ADD
|
||||
| DATEDIFF
|
||||
| DATE_DIFF
|
||||
|
||||
@ -31,10 +31,13 @@ import org.apache.doris.nereids.DorisParser.ColumnReferenceContext;
|
||||
import org.apache.doris.nereids.DorisParser.ComparisonContext;
|
||||
import org.apache.doris.nereids.DorisParser.CreateRowPolicyContext;
|
||||
import org.apache.doris.nereids.DorisParser.CteContext;
|
||||
import org.apache.doris.nereids.DorisParser.Date_addContext;
|
||||
import org.apache.doris.nereids.DorisParser.Date_subContext;
|
||||
import org.apache.doris.nereids.DorisParser.DecimalLiteralContext;
|
||||
import org.apache.doris.nereids.DorisParser.DereferenceContext;
|
||||
import org.apache.doris.nereids.DorisParser.ExistContext;
|
||||
import org.apache.doris.nereids.DorisParser.ExplainContext;
|
||||
import org.apache.doris.nereids.DorisParser.ExpressionContext;
|
||||
import org.apache.doris.nereids.DorisParser.FromClauseContext;
|
||||
import org.apache.doris.nereids.DorisParser.GroupingElementContext;
|
||||
import org.apache.doris.nereids.DorisParser.GroupingSetContext;
|
||||
@ -126,12 +129,24 @@ import org.apache.doris.nereids.trees.expressions.Subtract;
|
||||
import org.apache.doris.nereids.trees.expressions.TVFProperties;
|
||||
import org.apache.doris.nereids.trees.expressions.TimestampArithmetic;
|
||||
import org.apache.doris.nereids.trees.expressions.WhenClause;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DaysAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DaysDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DaysSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HoursAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HoursDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HoursSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinutesAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinutesDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinutesSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondsAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondsDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondsSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearsAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearsDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearsSub;
|
||||
import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
|
||||
import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral;
|
||||
import org.apache.doris.nereids.trees.expressions.literal.DateLiteral;
|
||||
@ -167,6 +182,8 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
|
||||
import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias;
|
||||
import org.apache.doris.nereids.trees.plans.logical.RelationUtil;
|
||||
import org.apache.doris.nereids.types.DataType;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
import org.apache.doris.nereids.types.TinyIntType;
|
||||
import org.apache.doris.nereids.util.ExpressionUtils;
|
||||
import org.apache.doris.policy.PolicyTypeEnum;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
@ -577,10 +594,82 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
|
||||
} else if ("SECOND".equalsIgnoreCase(unit)) {
|
||||
return new SecondsDiff(end, start);
|
||||
}
|
||||
throw new ParseException("Unsupported time stamp diff time unit: " + unit, ctx);
|
||||
throw new ParseException("Unsupported time stamp diff time unit: " + unit
|
||||
+ ", supported time unit: YEAR/MONTH/DAY/HOUR/MINUTE/SECOND", ctx);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression visitDate_add(Date_addContext ctx) {
|
||||
Expression timeStamp = (Expression) visit(ctx.timestamp);
|
||||
Expression amount = (Expression) visit(ctx.unitsAmount);
|
||||
if (ctx.unit == null) {
|
||||
if ("days_add".equalsIgnoreCase(ctx.name.getText())) {
|
||||
return new DaysAdd(timeStamp, amount);
|
||||
}
|
||||
throw new ParseException("Unsupported signature: " + ctx.name
|
||||
+ " needs time unit (YEAR/MONTH/DAY/HOUR/MINUTE/SECOND)", ctx);
|
||||
}
|
||||
|
||||
if ("DAY".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new DaysAdd(timeStamp, amount);
|
||||
}
|
||||
if ("MONTH".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new MonthsAdd(timeStamp, amount);
|
||||
}
|
||||
if ("Year".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new YearsAdd(timeStamp, amount);
|
||||
}
|
||||
if ("Hour".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new HoursAdd(timeStamp, amount);
|
||||
}
|
||||
if ("Minute".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new MinutesAdd(timeStamp, amount);
|
||||
}
|
||||
if ("Second".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new SecondsAdd(timeStamp, amount);
|
||||
}
|
||||
throw new ParseException("Unsupported time unit: " + ctx.unit
|
||||
+ ", supported time unit: YEAR/MONTH/DAY/HOUR/MINUTE/SECOND", ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression visitDate_sub(Date_subContext ctx) {
|
||||
Expression timeStamp = (Expression) visit(ctx.timestamp);
|
||||
Expression amount = (Expression) visit(ctx.unitsAmount);
|
||||
if (! (amount.getDataType() instanceof TinyIntType)) {
|
||||
amount = new Cast(amount, IntegerType.INSTANCE);
|
||||
}
|
||||
if (ctx.unit == null) {
|
||||
if ("days_sub".equalsIgnoreCase(ctx.name.getText())) {
|
||||
return new DaysSub(timeStamp, amount);
|
||||
}
|
||||
throw new ParseException("Unsupported signature: " + ctx.name
|
||||
+ " needs time unit (YEAR/MONTH/DAY/HOUR/MINUTE/SECOND)", ctx);
|
||||
}
|
||||
|
||||
if ("DAY".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new DaysSub(timeStamp, amount);
|
||||
}
|
||||
if ("MONTH".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new MonthsSub(timeStamp, amount);
|
||||
}
|
||||
if ("Year".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new YearsSub(timeStamp, amount);
|
||||
}
|
||||
if ("Hour".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new HoursSub(timeStamp, amount);
|
||||
}
|
||||
if ("Minute".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new MinutesSub(timeStamp, amount);
|
||||
}
|
||||
if ("Second".equalsIgnoreCase(ctx.unit.getText())) {
|
||||
return new SecondsSub(timeStamp, amount);
|
||||
}
|
||||
throw new ParseException("Unsupported time unit: " + ctx.unit
|
||||
+ ", supported time unit: YEAR/MONTH/DAY/HOUR/MINUTE/SECOND", ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a value based [[CaseWhen]] expression. This has the following SQL form:
|
||||
* {{{
|
||||
@ -648,7 +737,8 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
|
||||
// the function information is obtained by parsing the catalog. This method is more scalable.
|
||||
String functionName = ctx.identifier().getText();
|
||||
boolean isDistinct = ctx.DISTINCT() != null;
|
||||
List<Expression> params = visit(ctx.expression(), Expression.class);
|
||||
List<ExpressionContext> expressionContexts = ctx.expression();
|
||||
List<Expression> params = visit(expressionContexts, Expression.class);
|
||||
for (Expression expression : params) {
|
||||
if (expression instanceof UnboundStar && functionName.equalsIgnoreCase("count") && !isDistinct) {
|
||||
return new UnboundFunction(functionName, false, true, new ArrayList<>());
|
||||
|
||||
@ -48,6 +48,10 @@ import java.util.Objects;
|
||||
public class TimestampArithmetic extends Expression implements BinaryExpression, ImplicitCastInputTypes,
|
||||
PropagateNullable {
|
||||
|
||||
//the size and order of EXPECTED_INPUT_TYPES must follow the function signature parameters
|
||||
//For example: days_sub('2000-01-01', interval 5 days),
|
||||
// '2000-01-01'->DateTimeType.INSTANCE
|
||||
// 5 -> IntegerType
|
||||
private static final List<AbstractDataType> EXPECTED_INPUT_TYPES = ImmutableList.of(
|
||||
DateTimeType.INSTANCE,
|
||||
IntegerType.INSTANCE
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'days_add'.
|
||||
*/
|
||||
public class DaysAdd extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public DaysAdd(Expression arg0, Expression arg1) {
|
||||
super("days_add", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaysAdd withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new DaysAdd(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitDaysAdd(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'days_add'.
|
||||
*/
|
||||
public class DaysSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public DaysSub(Expression arg0, Expression arg1) {
|
||||
super("days_sub", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaysSub withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new DaysSub(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitDaysSub(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'days_add'.
|
||||
*/
|
||||
public class HoursAdd extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public HoursAdd(Expression arg0, Expression arg1) {
|
||||
super("hours_add", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HoursAdd withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new HoursAdd(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitHoursAdd(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'hours_sub'.
|
||||
*/
|
||||
public class HoursSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public HoursSub(Expression arg0, Expression arg1) {
|
||||
super("hours_sub", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HoursSub withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new HoursSub(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitHoursSub(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'minutes_add'.
|
||||
*/
|
||||
public class MinutesAdd extends ScalarFunction
|
||||
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public MinutesAdd(Expression arg0, Expression arg1) {
|
||||
super("minutes_add", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinutesAdd withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new MinutesAdd(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitMinutesAdd(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'minutes_sub'.
|
||||
*/
|
||||
public class MinutesSub extends ScalarFunction
|
||||
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public MinutesSub(Expression arg0, Expression arg1) {
|
||||
super("minutes_sub", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinutesSub withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new MinutesSub(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitMinutesSub(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'months_add'.
|
||||
*/
|
||||
public class MonthsAdd extends ScalarFunction
|
||||
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public MonthsAdd(Expression arg0, Expression arg1) {
|
||||
super("months_add", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonthsAdd withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new MonthsAdd(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitMonthsAdd(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'months_sub'.
|
||||
*/
|
||||
public class MonthsSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public MonthsSub(Expression arg0, Expression arg1) {
|
||||
super("months_sub", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonthsSub withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new MonthsSub(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitMonthsSub(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'minutes_add'.
|
||||
*/
|
||||
public class SecondsAdd extends ScalarFunction
|
||||
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public SecondsAdd(Expression arg0, Expression arg1) {
|
||||
super("seconds_add", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecondsAdd withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new SecondsAdd(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitSecondsAdd(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'Seconds_sub'.
|
||||
*/
|
||||
public class SecondsSub extends ScalarFunction
|
||||
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public SecondsSub(Expression arg0, Expression arg1) {
|
||||
super("Seconds_sub", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecondsSub withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new SecondsSub(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitSecondsSub(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'days_add'.
|
||||
*/
|
||||
public class YearsAdd extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public YearsAdd(Expression arg0, Expression arg1) {
|
||||
super("years_add", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YearsAdd withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new YearsAdd(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitYearsAdd(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateType;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.IntegerType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'days_add'.
|
||||
*/
|
||||
public class YearsSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
|
||||
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
|
||||
);
|
||||
|
||||
public YearsSub(Expression arg0, Expression arg1) {
|
||||
super("years_sub", arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YearsSub withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 2);
|
||||
return new YearsSub(children.get(0), children.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitYearsSub(this, context);
|
||||
}
|
||||
}
|
||||
@ -87,10 +87,10 @@ public abstract class Literal extends Expression implements LeafExpression, Comp
|
||||
* for numeric literal (int/long/double/float), directly convert to double
|
||||
* for char/varchar/string, we take first 8 chars as a int64, and convert it to double
|
||||
* for other literals, getDouble() is not used.
|
||||
*
|
||||
* <p>
|
||||
* And hence, we could express the range of a datatype, and used in stats derive.
|
||||
* for example:
|
||||
*'abcxxxxxxxxxxx' is between ('abb', 'zzz')
|
||||
* 'abcxxxxxxxxxxx' is between ('abb', 'zzz')
|
||||
*
|
||||
* @return double representation of literal.
|
||||
*/
|
||||
|
||||
@ -76,7 +76,9 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.DayName;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DayOfMonth;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DayOfWeek;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DayOfYear;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DaysAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DaysDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.DaysSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dceil;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Degrees;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dexp;
|
||||
@ -110,7 +112,9 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.HllHash;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Hour;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HourCeil;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HourFloor;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HoursAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HoursDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.HoursSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.If;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Initcap;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Instr;
|
||||
@ -156,13 +160,17 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.Md5Sum;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Minute;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinuteCeil;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinuteFloor;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinutesAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinutesDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MinutesSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MoneyFormat;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Month;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthCeil;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthFloor;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthName;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MurmurHash332;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.MurmurHash364;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Negative;
|
||||
@ -194,7 +202,9 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.ScalarFunctio
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Second;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondCeil;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondFloor;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondsAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondsDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.SecondsSub;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sign;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sin;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sleep;
|
||||
@ -254,7 +264,9 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.Year;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearCeil;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearFloor;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearWeek;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearsAdd;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearsDiff;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.YearsSub;
|
||||
|
||||
/** ScalarFunctionVisitor. */
|
||||
public interface ScalarFunctionVisitor<R, C> {
|
||||
@ -501,6 +513,54 @@ public interface ScalarFunctionVisitor<R, C> {
|
||||
return visitScalarFunction(daysDiff, context);
|
||||
}
|
||||
|
||||
default R visitDaysAdd(DaysAdd daysAdd, C context) {
|
||||
return visitScalarFunction(daysAdd, context);
|
||||
}
|
||||
|
||||
default R visitDaysSub(DaysSub daysSub, C context) {
|
||||
return visitScalarFunction(daysSub, context);
|
||||
}
|
||||
|
||||
default R visitYearsSub(YearsSub yearsSub, C context) {
|
||||
return visitScalarFunction(yearsSub, context);
|
||||
}
|
||||
|
||||
default R visitMonthsSub(MonthsSub monthsSub, C context) {
|
||||
return visitScalarFunction(monthsSub, context);
|
||||
}
|
||||
|
||||
default R visitHoursSub(HoursSub hoursSub, C context) {
|
||||
return visitScalarFunction(hoursSub, context);
|
||||
}
|
||||
|
||||
default R visitMinutesSub(MinutesSub minutesSub, C context) {
|
||||
return visitScalarFunction(minutesSub, context);
|
||||
}
|
||||
|
||||
default R visitSecondsSub(SecondsSub secondsSub, C context) {
|
||||
return visitScalarFunction(secondsSub, context);
|
||||
}
|
||||
|
||||
default R visitMonthsAdd(MonthsAdd monthsAdd, C context) {
|
||||
return visitScalarFunction(monthsAdd, context);
|
||||
}
|
||||
|
||||
default R visitYearsAdd(YearsAdd yearsAdd, C context) {
|
||||
return visitScalarFunction(yearsAdd, context);
|
||||
}
|
||||
|
||||
default R visitHoursAdd(HoursAdd hoursAdd, C context) {
|
||||
return visitScalarFunction(hoursAdd, context);
|
||||
}
|
||||
|
||||
default R visitMinutesAdd(MinutesAdd minutesAdd, C context) {
|
||||
return visitScalarFunction(minutesAdd, context);
|
||||
}
|
||||
|
||||
default R visitSecondsAdd(SecondsAdd secondsAdd, C context) {
|
||||
return visitScalarFunction(secondsAdd, context);
|
||||
}
|
||||
|
||||
default R visitDceil(Dceil dceil, C context) {
|
||||
return visitScalarFunction(dceil, context);
|
||||
}
|
||||
|
||||
49
regression-test/data/nereids_syntax_p0/test_date_add.out
Normal file
49
regression-test/data/nereids_syntax_p0/test_date_add.out
Normal file
@ -0,0 +1,49 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !select --
|
||||
2020-01-03T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-03T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-03T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-03T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-01T02:00
|
||||
|
||||
-- !select --
|
||||
2020-01-01T02:00
|
||||
|
||||
-- !select --
|
||||
2020-01-01T02:00
|
||||
|
||||
-- !select --
|
||||
2020-01-01T02:00
|
||||
|
||||
-- !select --
|
||||
2022-01-01T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-01T02:00
|
||||
|
||||
-- !select --
|
||||
2020-01-01T00:02
|
||||
|
||||
-- !select --
|
||||
2020-01-01T00:00:02
|
||||
|
||||
-- !select --
|
||||
2020-01-03T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-03T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-03T00:00
|
||||
|
||||
-- !select --
|
||||
2019-12-28T00:00
|
||||
|
||||
55
regression-test/data/nereids_syntax_p0/test_date_sub.out
Normal file
55
regression-test/data/nereids_syntax_p0/test_date_sub.out
Normal file
@ -0,0 +1,55 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !select --
|
||||
2018-01-01T00:00
|
||||
|
||||
-- !select --
|
||||
2018-01-01T00:00
|
||||
|
||||
-- !select --
|
||||
2018-01-01T00:00
|
||||
|
||||
-- !select --
|
||||
2018-01-01T00:00
|
||||
|
||||
-- !select --
|
||||
2018-01-01T00:00
|
||||
|
||||
-- !select --
|
||||
2019-12-31T23:58
|
||||
|
||||
-- !select --
|
||||
2019-12-31T23:58
|
||||
|
||||
-- !select --
|
||||
2019-12-31T23:58
|
||||
|
||||
-- !select --
|
||||
2019-12-31T23:58
|
||||
|
||||
-- !select --
|
||||
2019-12-31T23:58
|
||||
|
||||
-- !select --
|
||||
2019-12-30T00:00
|
||||
|
||||
-- !select --
|
||||
2019-12-31T22:00
|
||||
|
||||
-- !select --
|
||||
2019-12-31T23:58
|
||||
|
||||
-- !select --
|
||||
2019-12-31T23:59:58
|
||||
|
||||
-- !select --
|
||||
2019-12-30T00:00
|
||||
|
||||
-- !select --
|
||||
2019-12-30T00:00
|
||||
|
||||
-- !select --
|
||||
2019-12-30T00:00
|
||||
|
||||
-- !select --
|
||||
2020-01-05T00:00
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
suite("test_date_add") {
|
||||
sql "set enable_nereids_planner=true"
|
||||
sql "set enable_fallback_to_original_planner=false"
|
||||
sql "set enable_fold_constant_by_be=false"
|
||||
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as date), interval 2 day)"
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as datev2),interval 2 day)"
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as datetime), interval 2 day)"
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as datetimev2), interval 2 day)"
|
||||
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as date), interval 2 hour)"
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as datev2),interval 2 hour)"
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as datetime), interval 2 hour)"
|
||||
qt_select "select TIMESTAMPADD(cast('2020-01-01' as datetimev2), interval 2 hour)"
|
||||
qt_select "select TIMESTAMPADD('2020-01-01' , interval 2 year)"
|
||||
|
||||
qt_select "SELECT DAYS_ADD('2020-01-01', interval 2 hour)"
|
||||
qt_select "SELECT DAYS_ADD('2020-01-01', interval 2 minute)"
|
||||
qt_select "SELECT DAYS_ADD('2020-01-01', interval 2 second)"
|
||||
qt_select "SELECT DATE_ADD('2020-01-01', interval 2 day)"
|
||||
qt_select "SELECT ADDDATE('2020-01-01', interval 2 day)"
|
||||
qt_select "SELECT DAYS_ADD('2020-01-01', 2)"
|
||||
qt_select "SELECT DAYS_ADD('2020-01-01', -4)"
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
suite("test_date_sub") {
|
||||
sql "set enable_nereids_planner=true"
|
||||
sql "set enable_fallback_to_original_planner=false"
|
||||
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as date), interval 2 year)"
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as datev2),interval 2 year)"
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as datetime), interval 2 year)"
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as datetimev2), interval 2 year)"
|
||||
qt_select "select DAYS_SUB('2020-01-01' , interval 2 year)"
|
||||
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as date), interval 2 minute)"
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as datev2),interval 2 minute)"
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as datetime), interval 2 minute)"
|
||||
qt_select "select DAYS_SUB(cast('2020-01-01' as datetimev2), interval 2 minute)"
|
||||
qt_select "select DAYS_SUB('2020-01-01' , interval 2 minute)"
|
||||
|
||||
qt_select "SELECT DAYS_SUB('2020-01-01', interval 2 day)"
|
||||
qt_select "SELECT DAYS_SUB('2020-01-01', interval 2 hour)"
|
||||
qt_select "SELECT DAYS_SUB('2020-01-01', interval 2 minute)"
|
||||
qt_select "SELECT DAYS_SUB('2020-01-01', interval 2 second)"
|
||||
qt_select "SELECT DATE_SUB('2020-01-01', interval 2 day)"
|
||||
qt_select "SELECT SUBDATE('2020-01-01', interval 2 day)"
|
||||
qt_select "SELECT DAYS_SUB('2020-01-01', 2)"
|
||||
qt_select "SELECT DAYS_SUB('2020-01-01', -4)"
|
||||
}
|
||||
Reference in New Issue
Block a user