[feature](function) support sequence function(alias of array_range), enhance both to handle datetimev2 (#30823)

This commit is contained in:
Chester
2024-02-26 17:33:20 +08:00
committed by yiguolei
parent 22b6434054
commit f163d56a98
25 changed files with 1428 additions and 47 deletions

View File

@ -1776,6 +1776,13 @@ public class FunctionCallExpr extends Expr {
+ "year|quarter|month|week|day|hour|minute|second");
}
}
if (fnName.getFunction().equalsIgnoreCase("array_range")
|| fnName.getFunction().equalsIgnoreCase("sequence")) {
if (getChild(0) instanceof DateLiteral && !(getChild(2) instanceof StringLiteral)) {
throw new AnalysisException("To generate datetime array, please use interval literal like: "
+ "interval 1 day.");
}
}
if (fnName.getFunction().equalsIgnoreCase("char")) {
if (!getChild(0).isConstant()) {
throw new AnalysisException(

View File

@ -485,7 +485,7 @@ public class BuiltinScalarFunctions implements FunctionHelper {
scalar(ArrayProduct.class, "array_product"),
scalar(ArrayPushBack.class, "Array_pushback"),
scalar(ArrayPushFront.class, "Array_pushfront"),
scalar(ArrayRange.class, "array_range"),
scalar(ArrayRange.class, "array_range", "sequence"),
scalar(ArrayRemove.class, "array_remove"),
scalar(ArrayRepeat.class, "array_repeat"),
scalar(ArrayReverseSort.class, "array_reverse_sort"),

View File

@ -48,6 +48,7 @@ import org.apache.doris.nereids.DorisParser.AlterMTMVContext;
import org.apache.doris.nereids.DorisParser.ArithmeticBinaryContext;
import org.apache.doris.nereids.DorisParser.ArithmeticUnaryContext;
import org.apache.doris.nereids.DorisParser.ArrayLiteralContext;
import org.apache.doris.nereids.DorisParser.ArrayRangeContext;
import org.apache.doris.nereids.DorisParser.ArraySliceContext;
import org.apache.doris.nereids.DorisParser.BitOperationContext;
import org.apache.doris.nereids.DorisParser.BooleanExpressionContext;
@ -261,6 +262,14 @@ import org.apache.doris.nereids.trees.expressions.functions.Function;
import org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.functions.agg.GroupConcat;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Array;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRange;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeDayUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeHourUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeMinuteUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeMonthUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeSecondUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeWeekUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeYearUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArraySlice;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Char;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ConvertTo;
@ -1682,6 +1691,40 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
+ ", supported time unit: YEAR/MONTH/DAY/HOUR/MINUTE/SECOND", ctx);
}
@Override
public Expression visitArrayRange(ArrayRangeContext ctx) {
Expression start = (Expression) visit(ctx.start);
Expression end = (Expression) visit(ctx.end);
Expression step = (Expression) visit(ctx.unitsAmount);
String unit = ctx.unit.getText();
if (unit != null && !unit.isEmpty()) {
if ("Year".equalsIgnoreCase(unit)) {
return new ArrayRangeYearUnit(start, end, step);
} else if ("Month".equalsIgnoreCase(unit)) {
return new ArrayRangeMonthUnit(start, end, step);
} else if ("Week".equalsIgnoreCase(unit)) {
return new ArrayRangeWeekUnit(start, end, step);
} else if ("Day".equalsIgnoreCase(unit)) {
return new ArrayRangeDayUnit(start, end, step);
} else if ("Hour".equalsIgnoreCase(unit)) {
return new ArrayRangeHourUnit(start, end, step);
} else if ("Minute".equalsIgnoreCase(unit)) {
return new ArrayRangeMinuteUnit(start, end, step);
} else if ("Second".equalsIgnoreCase(unit)) {
return new ArrayRangeSecondUnit(start, end, step);
}
throw new ParseException("Unsupported time unit: " + ctx.unit
+ ", supported time unit: YEAR/MONTH/DAY/HOUR/MINUTE/SECOND", ctx);
} else if (ctx.unitsAmount != null) {
return new ArrayRange(start, end, step);
} else if (ctx.end != null) {
return new ArrayRange(start, end);
} else {
return new ArrayRange(start);
}
}
@Override
public Expression visitDate_sub(Date_subContext ctx) {
Expression timeStamp = (Expression) visit(ctx.timestamp);

View File

@ -23,6 +23,7 @@ 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.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
@ -40,7 +41,11 @@ public class ArrayRange extends ScalarFunction
FunctionSignature.ret(ArrayType.of(IntegerType.INSTANCE)).args(IntegerType.INSTANCE),
FunctionSignature.ret(ArrayType.of(IntegerType.INSTANCE)).args(IntegerType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(ArrayType.of(IntegerType.INSTANCE))
.args(IntegerType.INSTANCE, IntegerType.INSTANCE, IntegerType.INSTANCE)
.args(IntegerType.INSTANCE, IntegerType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**

View File

@ -0,0 +1,70 @@
// 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.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'array_range_day_unit'.
*/
public class ArrayRangeDayUnit extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public ArrayRangeDayUnit(Expression arg0, Expression arg1, Expression arg2) {
super("array_range_day_unit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ArrayRangeDayUnit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ArrayRangeDayUnit(children.get(0), children.get(1), children.get(2));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayRangeDayUnit(this, context);
}
}

View File

@ -0,0 +1,70 @@
// 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.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'array_range_hour_unit'.
*/
public class ArrayRangeHourUnit extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public ArrayRangeHourUnit(Expression arg0, Expression arg1, Expression arg2) {
super("array_range_hour_unit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ArrayRangeHourUnit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ArrayRangeHourUnit(children.get(0), children.get(1), children.get(2));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayRangeHourUnit(this, context);
}
}

View File

@ -0,0 +1,70 @@
// 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.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'array_range_minute_unit'.
*/
public class ArrayRangeMinuteUnit extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public ArrayRangeMinuteUnit(Expression arg0, Expression arg1, Expression arg2) {
super("array_range_minute_unit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ArrayRangeMinuteUnit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ArrayRangeMinuteUnit(children.get(0), children.get(1), children.get(2));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayRangeMinuteUnit(this, context);
}
}

View File

@ -0,0 +1,70 @@
// 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.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'array_range_month_unit'.
*/
public class ArrayRangeMonthUnit extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public ArrayRangeMonthUnit(Expression arg0, Expression arg1, Expression arg2) {
super("array_range_month_unit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ArrayRangeMonthUnit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ArrayRangeMonthUnit(children.get(0), children.get(1), children.get(2));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayRangeMonthUnit(this, context);
}
}

View File

@ -0,0 +1,70 @@
// 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.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'array_range_second_unit'.
*/
public class ArrayRangeSecondUnit extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public ArrayRangeSecondUnit(Expression arg0, Expression arg1, Expression arg2) {
super("array_range_second_unit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ArrayRangeSecondUnit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ArrayRangeSecondUnit(children.get(0), children.get(1), children.get(2));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayRangeSecondUnit(this, context);
}
}

View File

@ -0,0 +1,70 @@
// 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.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'array_range_week_unit'.
*/
public class ArrayRangeWeekUnit extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public ArrayRangeWeekUnit(Expression arg0, Expression arg1, Expression arg2) {
super("array_range_week_unit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ArrayRangeWeekUnit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ArrayRangeWeekUnit(children.get(0), children.get(1), children.get(2));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayRangeWeekUnit(this, context);
}
}

View File

@ -0,0 +1,70 @@
// 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.ArrayType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'array_range_year_unit'.
*/
public class ArrayRangeYearUnit extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public ArrayRangeYearUnit(Expression arg0, Expression arg1, Expression arg2) {
super("array_range_year_unit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ArrayRangeYearUnit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ArrayRangeYearUnit(children.get(0), children.get(1), children.get(2));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayRangeYearUnit(this, context);
}
}

View File

@ -57,6 +57,13 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayProduct;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayPushBack;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayPushFront;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRange;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeDayUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeHourUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeMinuteUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeMonthUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeSecondUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeWeekUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRangeYearUnit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRemove;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayRepeat;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ArrayReverseSort;
@ -573,6 +580,34 @@ public interface ScalarFunctionVisitor<R, C> {
return visitScalarFunction(arrayRange, context);
}
default R visitArrayRangeDayUnit(ArrayRangeDayUnit arrayRangeDayUnit, C context) {
return visitScalarFunction(arrayRangeDayUnit, context);
}
default R visitArrayRangeHourUnit(ArrayRangeHourUnit arrayRangeHourUnit, C context) {
return visitScalarFunction(arrayRangeHourUnit, context);
}
default R visitArrayRangeMinuteUnit(ArrayRangeMinuteUnit arrayRangeMinuteUnit, C context) {
return visitScalarFunction(arrayRangeMinuteUnit, context);
}
default R visitArrayRangeMonthUnit(ArrayRangeMonthUnit arrayRangeMonthUnit, C context) {
return visitScalarFunction(arrayRangeMonthUnit, context);
}
default R visitArrayRangeSecondUnit(ArrayRangeSecondUnit arrayRangeSecondUnit, C context) {
return visitScalarFunction(arrayRangeSecondUnit, context);
}
default R visitArrayRangeWeekUnit(ArrayRangeWeekUnit arrayRangeWeekUnit, C context) {
return visitScalarFunction(arrayRangeWeekUnit, context);
}
default R visitArrayRangeYearUnit(ArrayRangeYearUnit arrayRangeYearUnit, C context) {
return visitScalarFunction(arrayRangeYearUnit, context);
}
default R visitArrayRemove(ArrayRemove arrayRemove, C context) {
return visitScalarFunction(arrayRemove, context);
}