[feature](Nereids) Support lots of scalar function and fix some bug (#13764)

Proposed changes
1. function interfaces that can search the matched signature, say ComputeSignature. It's equal to the Function.CompareMode.
   - IdenticalSignature: equal to Function.CompareMode.IS_IDENTICAL
   - NullOrIdenticalSignature: equal to Function.CompareMode.IS_INDISTINGUISHABLE
   - ImplicitlyCastableSignature: equal to Function.CompareMode.IS_SUPERTYPE_OF
   - ExplicitlyCastableSignature: equal to Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF
3. generate lots of scalar functions
4. bug-fix: disassemble avg function compute wrong result because the wrong input type, the AggregateParam.inputTypesBeforeDissemble is use to save the origin input type and pass to backend to find the correct global aggregate function.
5. bug-fix: subquery with OneRowRelation will crash because wrong nullable property


Note:
1. currently no more unit test/regression test for the scalar functions, I will add the test until migrate aggregate functions for unified processing.
2. A known problem is can not invoke the variable length function, I will fix it later.
This commit is contained in:
924060929
2022-11-02 18:01:08 +08:00
committed by GitHub
parent a871fef815
commit 6eea855e78
335 changed files with 22638 additions and 742 deletions

View File

@ -61,32 +61,33 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
// TODO: for aggregations, we need to unify the code paths for builtins and UDAs.
public class FunctionCallExpr extends Expr {
private static final ImmutableSet<String> STDDEV_FUNCTION_SET =
public static final ImmutableSet<String> STDDEV_FUNCTION_SET =
new ImmutableSortedSet.Builder(String.CASE_INSENSITIVE_ORDER)
.add("stddev").add("stddev_val").add("stddev_samp").add("stddev_pop")
.add("variance").add("variance_pop").add("variance_pop").add("var_samp").add("var_pop").build();
private static final ImmutableSet<String> DECIMAL_SAME_TYPE_SET =
public static final ImmutableSet<String> DECIMAL_SAME_TYPE_SET =
new ImmutableSortedSet.Builder(String.CASE_INSENSITIVE_ORDER)
.add("min").add("max").add("lead").add("lag")
.add("first_value").add("last_value").add("abs")
.add("positive").add("negative").build();
private static final ImmutableSet<String> DECIMAL_WIDER_TYPE_SET =
public static final ImmutableSet<String> DECIMAL_WIDER_TYPE_SET =
new ImmutableSortedSet.Builder(String.CASE_INSENSITIVE_ORDER)
.add("sum").add("avg").add("multi_distinct_sum").build();
private static final ImmutableSet<String> DECIMAL_FUNCTION_SET =
public static final ImmutableSet<String> DECIMAL_FUNCTION_SET =
new ImmutableSortedSet.Builder<>(String.CASE_INSENSITIVE_ORDER)
.addAll(DECIMAL_SAME_TYPE_SET)
.addAll(DECIMAL_WIDER_TYPE_SET)
.addAll(STDDEV_FUNCTION_SET).build();
private static final ImmutableSet<String> TIME_FUNCTIONS_WITH_PRECISION =
public static final ImmutableSet<String> TIME_FUNCTIONS_WITH_PRECISION =
new ImmutableSortedSet.Builder(String.CASE_INSENSITIVE_ORDER)
.add("now").add("current_timestamp").add("localtime").add("localtimestamp").build();
private static final int STDDEV_DECIMAL_SCALE = 9;
public static final int STDDEV_DECIMAL_SCALE = 9;
private static final String ELEMENT_EXTRACT_FN_NAME = "%element_extract%";
private static final Logger LOG = LogManager.getLogger(FunctionCallExpr.class);
@ -116,6 +117,12 @@ public class FunctionCallExpr extends Expr {
private boolean isRewrote = false;
// TODO: this field will be removed when we support analyze aggregate function in the nereids framework.
private boolean shouldFinalizeForNereids = true;
// this field is set by nereids, so we would not get arg types by the children.
private Optional<List<Type>> argTypesForNereids = Optional.empty();
public void setAggFnParams(FunctionParams aggFnParams) {
this.aggFnParams = aggFnParams;
}
@ -199,6 +206,28 @@ public class FunctionCallExpr extends Expr {
originChildSize = children.size();
}
public FunctionCallExpr(String functionName, FunctionParams params, Optional<List<Type>> argTypes) {
this.fnName = new FunctionName(functionName);
this.fnParams = params;
this.isMergeAggFn = false;
if (fnParams.exprs() != null) {
children.addAll(fnParams.exprs());
}
this.originChildSize = children.size();
this.argTypesForNereids = argTypes;
}
// nereids constructor without finalize/analyze
public FunctionCallExpr(FunctionName functionName, Function function, FunctionParams functionParams) {
this.fnName = functionName;
this.fn = function;
this.type = function.getReturnType();
if (functionParams.exprs() != null) {
this.children.addAll(functionParams.exprs());
}
this.shouldFinalizeForNereids = false;
}
// Constructs the same agg function with new params.
public FunctionCallExpr(FunctionCallExpr e, FunctionParams params) {
Preconditions.checkState(e.isAnalyzed);
@ -1496,11 +1525,17 @@ public class FunctionCallExpr extends Expr {
}
public void finalizeImplForNereids() throws AnalysisException {
// return if nereids already analyzed out of the FunctionCallExpr.
if (!shouldFinalizeForNereids) {
return;
}
List<Type> argTypes = getArgTypesForNereids();
// TODO: support other functions
// TODO: Supports type conversion to match the type of the function's parameters
if (fnName.getFunction().equalsIgnoreCase("sum")) {
// Prevent the cast type in vector exec engine
Type childType = getChild(0).type.getMaxResolutionType();
Type childType = argTypes.get(0).getMaxResolutionType();
fn = getBuiltinFunction(fnName.getFunction(), new Type[] {childType},
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
type = fn.getReturnType();
@ -1509,7 +1544,7 @@ public class FunctionCallExpr extends Expr {
type = fn.getReturnType();
} else if (fnName.getFunction().equalsIgnoreCase("substring")
|| fnName.getFunction().equalsIgnoreCase("cast")) {
Type[] childTypes = getChildren().stream().map(t -> t.type).toArray(Type[]::new);
Type[] childTypes = argTypes.stream().toArray(Type[]::new);
fn = getBuiltinFunction(fnName.getFunction(), childTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
type = fn.getReturnType();
} else if (fnName.getFunction().equalsIgnoreCase("year")
@ -1517,10 +1552,23 @@ public class FunctionCallExpr extends Expr {
|| fnName.getFunction().equalsIgnoreCase("min")
|| fnName.getFunction().equalsIgnoreCase("avg")
|| fnName.getFunction().equalsIgnoreCase("weekOfYear")) {
Type childType = getChild(0).type;
Type childType = argTypes.get(0);
fn = getBuiltinFunction(fnName.getFunction(), new Type[] {childType},
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
type = fn.getReturnType();
} else {
Type[] inputTypes = argTypes.stream().toArray(Type[]::new);
// nereids already compute the correct signature, so we can find the
fn = getBuiltinFunction(fnName.getFunction(), inputTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
type = fn.getReturnType();
}
}
private List<Type> getArgTypesForNereids() {
if (argTypesForNereids.isPresent()) {
return argTypesForNereids.get();
} else {
return Lists.newArrayList(collectChildReturnTypes());
}
}

View File

@ -22,27 +22,16 @@ import org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.functions.agg.Max;
import org.apache.doris.nereids.trees.expressions.functions.agg.Min;
import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Substring;
import org.apache.doris.nereids.trees.expressions.functions.scalar.WeekOfYear;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Year;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* Built-in functions.
* Builtin aggregate functions.
*
* Note: Please ensure that this class only has some lists and no procedural code.
* It helps to be clear and concise.
*/
public class BuiltinFunctions implements FunctionHelper {
public final List<ScalarFunc> scalarFunctions = ImmutableList.of(
scalar(Substring.class, "substr", "substring"),
scalar(WeekOfYear.class),
scalar(Year.class)
);
public class BuiltinAggregateFunctions implements FunctionHelper {
public final ImmutableList<AggregateFunc> aggregateFunctions = ImmutableList.of(
agg(Avg.class),
agg(Count.class),
@ -51,8 +40,8 @@ public class BuiltinFunctions implements FunctionHelper {
agg(Sum.class)
);
public static final BuiltinFunctions INSTANCE = new BuiltinFunctions();
public static final BuiltinAggregateFunctions INSTANCE = new BuiltinAggregateFunctions();
// Note: Do not add any code here!
private BuiltinFunctions() {}
private BuiltinAggregateFunctions() {}
}

View File

@ -0,0 +1,511 @@
// 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.catalog;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Abs;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Acos;
import org.apache.doris.nereids.trees.expressions.functions.scalar.AesDecrypt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.AesEncrypt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.AppendTrailingCharIfAbsent;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Ascii;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Asin;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Atan;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Bin;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitLength;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapAnd;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapAndCount;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapAndNot;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapAndNotCount;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapContains;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapCount;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapEmpty;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapFromString;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapHasAll;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapHasAny;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapHash;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapHash64;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapMax;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapMin;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapNot;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapOr;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapOrCount;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapSubsetInRange;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapSubsetLimit;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapToString;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapXor;
import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapXorCount;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Cbrt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Ceil;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Ceiling;
import org.apache.doris.nereids.trees.expressions.functions.scalar.CharLength;
import org.apache.doris.nereids.trees.expressions.functions.scalar.CharacterLength;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Coalesce;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Concat;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ConcatWs;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Conv;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ConvertTz;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Cos;
import org.apache.doris.nereids.trees.expressions.functions.scalar.CurrentDate;
import org.apache.doris.nereids.trees.expressions.functions.scalar.CurrentTime;
import org.apache.doris.nereids.trees.expressions.functions.scalar.CurrentTimestamp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Curtime;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Date;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DateDiff;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DateFormat;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DateTrunc;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DateV2;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Day;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DayCeil;
import org.apache.doris.nereids.trees.expressions.functions.scalar.DayFloor;
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.DaysDiff;
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;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dfloor;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dlog1;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dlog10;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dpow;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dround;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dsqrt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.E;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Elt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.EndsWith;
import org.apache.doris.nereids.trees.expressions.functions.scalar.EsQuery;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Exp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ExtractUrlParameter;
import org.apache.doris.nereids.trees.expressions.functions.scalar.FindInSet;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Floor;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Fmod;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Fpow;
import org.apache.doris.nereids.trees.expressions.functions.scalar.FromBase64;
import org.apache.doris.nereids.trees.expressions.functions.scalar.FromDays;
import org.apache.doris.nereids.trees.expressions.functions.scalar.FromUnixtime;
import org.apache.doris.nereids.trees.expressions.functions.scalar.GetJsonDouble;
import org.apache.doris.nereids.trees.expressions.functions.scalar.GetJsonInt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.GetJsonString;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Greatest;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Hex;
import org.apache.doris.nereids.trees.expressions.functions.scalar.HllCardinality;
import org.apache.doris.nereids.trees.expressions.functions.scalar.HllEmpty;
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.HoursDiff;
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;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonArray;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonObject;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonQuote;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExistsPath;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExtract;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExtractBigint;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExtractBool;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExtractDouble;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExtractInt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExtractIsnull;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbExtractString;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParse;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseErrorToInvalid;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseErrorToNull;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseErrorToValue;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNotnull;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNotnullErrorToInvalid;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNotnullErrorToValue;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullable;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullableErrorToInvalid;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullableErrorToNull;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullableErrorToValue;
import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbType;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Least;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Left;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Length;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Ln;
import org.apache.doris.nereids.trees.expressions.functions.scalar.LocalTime;
import org.apache.doris.nereids.trees.expressions.functions.scalar.LocalTimestamp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Locate;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Log;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Log10;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Log2;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Lower;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Lpad;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Ltrim;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MakeDate;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Md5;
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.MinutesDiff;
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.MonthsDiff;
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;
import org.apache.doris.nereids.trees.expressions.functions.scalar.NotNullOrEmpty;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Now;
import org.apache.doris.nereids.trees.expressions.functions.scalar.NullIf;
import org.apache.doris.nereids.trees.expressions.functions.scalar.NullOrEmpty;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Nvl;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ParseUrl;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Pi;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Pmod;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Positive;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Pow;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Power;
import org.apache.doris.nereids.trees.expressions.functions.scalar.QuantilePercent;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Quarter;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Radians;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Random;
import org.apache.doris.nereids.trees.expressions.functions.scalar.RegexpExtract;
import org.apache.doris.nereids.trees.expressions.functions.scalar.RegexpReplace;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Repeat;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Replace;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Reverse;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Right;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Round;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Rpad;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Rtrim;
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.SecondsDiff;
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;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sm3;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sm3sum;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sm4Decrypt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sm4Encrypt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Space;
import org.apache.doris.nereids.trees.expressions.functions.scalar.SplitPart;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Sqrt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAstext;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAswkt;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StCircle;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StContains;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StDistanceSphere;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeometryfromtext;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeomfromtext;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StLinefromtext;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StLinestringfromtext;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StPoint;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StPolyfromtext;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StPolygon;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StPolygonfromtext;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StX;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StY;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StartsWith;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StrLeft;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StrRight;
import org.apache.doris.nereids.trees.expressions.functions.scalar.StrToDate;
import org.apache.doris.nereids.trees.expressions.functions.scalar.SubBitmap;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Substring;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Tan;
import org.apache.doris.nereids.trees.expressions.functions.scalar.TimeDiff;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Timestamp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToBase64;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToBitmap;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToBitmapWithCheck;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToDate;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToDateV2;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToDays;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToQuantileState;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Trim;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Truncate;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Unhex;
import org.apache.doris.nereids.trees.expressions.functions.scalar.UnixTimestamp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Upper;
import org.apache.doris.nereids.trees.expressions.functions.scalar.UtcTimestamp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Version;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Week;
import org.apache.doris.nereids.trees.expressions.functions.scalar.WeekCeil;
import org.apache.doris.nereids.trees.expressions.functions.scalar.WeekFloor;
import org.apache.doris.nereids.trees.expressions.functions.scalar.WeekOfYear;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Weekday;
import org.apache.doris.nereids.trees.expressions.functions.scalar.WeeksDiff;
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.YearsDiff;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* Builtin scalar functions.
*
* Note: Please ensure that this class only has some lists and no procedural code.
* It helps to be clear and concise.
*/
public class BuiltinScalarFunctions implements FunctionHelper {
public final List<ScalarFunc> scalarFunctions = ImmutableList.of(
scalar(Abs.class, "abs"),
scalar(Acos.class, "acos"),
scalar(AesDecrypt.class, "aes_decrypt"),
scalar(AesEncrypt.class, "aes_encrypt"),
scalar(AppendTrailingCharIfAbsent.class, "append_trailing_char_if_absent"),
scalar(Ascii.class, "ascii"),
scalar(Asin.class, "asin"),
scalar(Atan.class, "atan"),
scalar(Bin.class, "bin"),
scalar(BitLength.class, "bit_length"),
scalar(BitmapAnd.class, "bitmap_and"),
scalar(BitmapAndCount.class, "bitmap_and_count"),
scalar(BitmapAndNot.class, "bitmap_and_not"),
scalar(BitmapAndNotCount.class, "bitmap_and_not_count"),
scalar(BitmapContains.class, "bitmap_contains"),
scalar(BitmapCount.class, "bitmap_count"),
scalar(BitmapEmpty.class, "bitmap_empty"),
scalar(BitmapFromString.class, "bitmap_from_string"),
scalar(BitmapHasAll.class, "bitmap_has_all"),
scalar(BitmapHasAny.class, "bitmap_has_any"),
scalar(BitmapHash.class, "bitmap_hash"),
scalar(BitmapHash64.class, "bitmap_hash64"),
scalar(BitmapMax.class, "bitmap_max"),
scalar(BitmapMin.class, "bitmap_min"),
scalar(BitmapNot.class, "bitmap_not"),
scalar(BitmapOr.class, "bitmap_or"),
scalar(BitmapOrCount.class, "bitmap_or_count"),
scalar(BitmapSubsetInRange.class, "bitmap_subset_in_range"),
scalar(BitmapSubsetLimit.class, "bitmap_subset_limit"),
scalar(BitmapToString.class, "bitmap_to_string"),
scalar(BitmapXor.class, "bitmap_xor"),
scalar(BitmapXorCount.class, "bitmap_xor_count"),
scalar(Cbrt.class, "cbrt"),
scalar(Ceil.class, "ceil"),
scalar(Ceiling.class, "ceiling"),
scalar(CharLength.class, "char_length"),
scalar(CharacterLength.class, "character_length"),
scalar(Coalesce.class, "coalesce"),
scalar(Concat.class, "concat"),
scalar(ConcatWs.class, "concat_ws"),
scalar(Conv.class, "conv"),
scalar(ConvertTz.class, "convert_tz"),
scalar(Cos.class, "cos"),
scalar(CurrentDate.class, "curdate", "current_date"),
scalar(CurrentTime.class, "current_time"),
scalar(CurrentTimestamp.class, "current_timestamp"),
scalar(Curtime.class, "curtime"),
scalar(Date.class, "date"),
scalar(DateDiff.class, "datediff"),
scalar(DateFormat.class, "date_format"),
scalar(DateTrunc.class, "date_trunc"),
scalar(DateV2.class, "datev2"),
scalar(Day.class, "day"),
scalar(DayCeil.class, "day_ceil"),
scalar(DayFloor.class, "day_floor"),
scalar(DayName.class, "dayname"),
scalar(DayOfMonth.class, "dayofmonth"),
scalar(DayOfWeek.class, "dayofweek"),
scalar(DayOfYear.class, "dayofyear"),
scalar(DaysDiff.class, "days_diff"),
scalar(Dceil.class, "dceil"),
scalar(Degrees.class, "degrees"),
scalar(Dexp.class, "dexp"),
scalar(Dfloor.class, "dfloor"),
scalar(Dlog1.class, "dlog1"),
scalar(Dlog10.class, "dlog10"),
scalar(Dpow.class, "dpow"),
scalar(Dround.class, "dround"),
scalar(Dsqrt.class, "dsqrt"),
scalar(E.class, "e"),
scalar(Elt.class, "elt"),
scalar(EndsWith.class, "ends_with"),
scalar(EsQuery.class, "esquery"),
scalar(Exp.class, "exp"),
scalar(ExtractUrlParameter.class, "extract_url_parameter"),
scalar(FindInSet.class, "find_in_set"),
scalar(Floor.class, "floor"),
scalar(Fmod.class, "fmod"),
scalar(Fpow.class, "fpow"),
scalar(FromBase64.class, "from_base64"),
scalar(FromDays.class, "from_days"),
scalar(FromUnixtime.class, "from_unixtime"),
scalar(GetJsonDouble.class, "get_json_double"),
scalar(GetJsonInt.class, "get_json_int"),
scalar(GetJsonString.class, "get_json_string"),
scalar(Greatest.class, "greatest"),
scalar(Hex.class, "hex"),
scalar(HllCardinality.class, "hll_cardinality"),
scalar(HllEmpty.class, "hll_empty"),
scalar(HllHash.class, "hll_hash"),
scalar(Hour.class, "hour"),
scalar(HourCeil.class, "hour_ceil"),
scalar(HourFloor.class, "hour_floor"),
scalar(HoursDiff.class, "hours_diff"),
scalar(If.class, "if"),
scalar(Initcap.class, "initcap"),
scalar(Instr.class, "instr"),
scalar(JsonArray.class, "json_array"),
scalar(JsonObject.class, "json_object"),
scalar(JsonQuote.class, "json_quote"),
scalar(JsonbExistsPath.class, "jsonb_exists_path"),
scalar(JsonbExtract.class, "jsonb_extract"),
scalar(JsonbExtractBigint.class, "jsonb_extract_bigint"),
scalar(JsonbExtractBool.class, "jsonb_extract_bool"),
scalar(JsonbExtractDouble.class, "jsonb_extract_double"),
scalar(JsonbExtractInt.class, "jsonb_extract_int"),
scalar(JsonbExtractIsnull.class, "jsonb_extract_isnull"),
scalar(JsonbExtractString.class, "jsonb_extract_string"),
scalar(JsonbParse.class, "jsonb_parse"),
scalar(JsonbParseErrorToInvalid.class, "jsonb_parse_error_to_invalid"),
scalar(JsonbParseErrorToNull.class, "jsonb_parse_error_to_null"),
scalar(JsonbParseErrorToValue.class, "jsonb_parse_error_to_value"),
scalar(JsonbParseNotnull.class, "jsonb_parse_notnull"),
scalar(JsonbParseNotnullErrorToInvalid.class, "jsonb_parse_notnull_error_to_invalid"),
scalar(JsonbParseNotnullErrorToValue.class, "jsonb_parse_notnull_error_to_value"),
scalar(JsonbParseNullable.class, "jsonb_parse_nullable"),
scalar(JsonbParseNullableErrorToInvalid.class, "jsonb_parse_nullable_error_to_invalid"),
scalar(JsonbParseNullableErrorToNull.class, "jsonb_parse_nullable_error_to_null"),
scalar(JsonbParseNullableErrorToValue.class, "jsonb_parse_nullable_error_to_value"),
scalar(JsonbType.class, "jsonb_type"),
scalar(Least.class, "least"),
scalar(Left.class, "left"),
scalar(Length.class, "length"),
scalar(Ln.class, "ln"),
scalar(LocalTime.class, "localtime"),
scalar(LocalTimestamp.class, "localtimestamp"),
scalar(Locate.class, "locate"),
scalar(Log.class, "log"),
scalar(Log10.class, "log10"),
scalar(Log2.class, "log2"),
scalar(Lower.class, "lcase", "lower"),
scalar(Lpad.class, "lpad"),
scalar(Ltrim.class, "ltrim"),
scalar(MakeDate.class, "makedate"),
scalar(Md5.class, "md5"),
scalar(Md5Sum.class, "md5sum"),
scalar(Minute.class, "minute"),
scalar(MinuteCeil.class, "minute_ceil"),
scalar(MinuteFloor.class, "minute_floor"),
scalar(MinutesDiff.class, "minutes_diff"),
scalar(MoneyFormat.class, "money_format"),
scalar(Month.class, "month"),
scalar(MonthCeil.class, "month_ceil"),
scalar(MonthFloor.class, "month_floor"),
scalar(MonthName.class, "monthname"),
scalar(MonthsDiff.class, "months_diff"),
scalar(MurmurHash332.class, "murmur_hash3_32"),
scalar(MurmurHash364.class, "murmur_hash3_64"),
scalar(Negative.class, "negative"),
scalar(NotNullOrEmpty.class, "not_null_or_empty"),
scalar(Now.class, "now"),
scalar(NullIf.class, "nullif"),
scalar(NullOrEmpty.class, "null_or_empty"),
scalar(Nvl.class, "ifnull", "nvl"),
scalar(ParseUrl.class, "parse_url"),
scalar(Pi.class, "pi"),
scalar(Pmod.class, "pmod"),
scalar(Positive.class, "positive"),
scalar(Pow.class, "pow"),
scalar(Power.class, "power"),
scalar(QuantilePercent.class, "quantile_percent"),
scalar(Quarter.class, "quarter"),
scalar(Radians.class, "radians"),
scalar(Random.class, "rand", "random"),
scalar(RegexpExtract.class, "regexp_extract"),
scalar(RegexpReplace.class, "regexp_replace"),
scalar(Repeat.class, "repeat"),
scalar(Replace.class, "replace"),
scalar(Reverse.class, "reverse"),
scalar(Right.class, "right"),
scalar(Round.class, "round"),
scalar(Rpad.class, "rpad"),
scalar(Rtrim.class, "rtrim"),
scalar(Second.class, "second"),
scalar(SecondCeil.class, "second_ceil"),
scalar(SecondFloor.class, "second_floor"),
scalar(SecondsDiff.class, "seconds_diff"),
scalar(Sign.class, "sign"),
scalar(Sin.class, "sin"),
scalar(Sleep.class, "sleep"),
scalar(Sm3.class, "sm3"),
scalar(Sm3sum.class, "sm3sum"),
scalar(Sm4Decrypt.class, "sm4_decrypt"),
scalar(Sm4Encrypt.class, "sm4_encrypt"),
scalar(Space.class, "space"),
scalar(SplitPart.class, "split_part"),
scalar(Sqrt.class, "sqrt"),
scalar(StAstext.class, "st_astext"),
scalar(StAswkt.class, "st_aswkt"),
scalar(StCircle.class, "st_circle"),
scalar(StContains.class, "st_contains"),
scalar(StDistanceSphere.class, "st_distance_sphere"),
scalar(StGeometryfromtext.class, "st_geometryfromtext"),
scalar(StGeomfromtext.class, "st_geomfromtext"),
scalar(StLinefromtext.class, "st_linefromtext"),
scalar(StLinestringfromtext.class, "st_linestringfromtext"),
scalar(StPoint.class, "st_point"),
scalar(StPolyfromtext.class, "st_polyfromtext"),
scalar(StPolygon.class, "st_polygon"),
scalar(StPolygonfromtext.class, "st_polygonfromtext"),
scalar(StX.class, "st_x"),
scalar(StY.class, "st_y"),
scalar(StartsWith.class, "starts_with"),
scalar(StrLeft.class, "strleft"),
scalar(StrRight.class, "strright"),
scalar(StrToDate.class, "str_to_date"),
scalar(SubBitmap.class, "sub_bitmap"),
scalar(Substring.class, "substr", "substring"),
scalar(Tan.class, "tan"),
scalar(TimeDiff.class, "timediff"),
scalar(Timestamp.class, "timestamp"),
scalar(ToBase64.class, "to_base64"),
scalar(ToBitmap.class, "to_bitmap"),
scalar(ToBitmapWithCheck.class, "to_bitmap_with_check"),
scalar(ToDate.class, "to_date"),
scalar(ToDateV2.class, "to_datev2"),
scalar(ToDays.class, "to_days"),
scalar(ToQuantileState.class, "to_quantile_state"),
scalar(Trim.class, "trim"),
scalar(Truncate.class, "truncate"),
scalar(Unhex.class, "unhex"),
scalar(UnixTimestamp.class, "unix_timestamp"),
scalar(Upper.class, "ucase", "upper"),
scalar(UtcTimestamp.class, "utc_timestamp"),
scalar(Version.class, "version"),
scalar(Week.class, "week"),
scalar(WeekCeil.class, "week_ceil"),
scalar(WeekFloor.class, "week_floor"),
scalar(WeekOfYear.class, "weekofyear"),
scalar(Weekday.class, "weekday"),
scalar(WeeksDiff.class, "weeks_diff"),
scalar(Year.class, "year"),
scalar(YearCeil.class, "year_ceil"),
scalar(YearFloor.class, "year_floor"),
scalar(YearWeek.class, "yearweek"),
scalar(YearsDiff.class, "years_diff")
);
public static final BuiltinScalarFunctions INSTANCE = new BuiltinScalarFunctions();
// Note: Do not add any code here!
private BuiltinScalarFunctions() {}
}

View File

@ -1,76 +0,0 @@
// 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.catalog;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class FuncSig {
public final DataType returnType;
public final boolean hasVarArgs;
public final List<AbstractDataType> argumentsTypes;
public FuncSig(DataType returnType, boolean hasVarArgs, List<DataType> argumentsTypes) {
this.returnType = Objects.requireNonNull(returnType, "returnType is not null");
this.argumentsTypes = ImmutableList.copyOf(
Objects.requireNonNull(argumentsTypes, "argumentsTypes is not null"));
this.hasVarArgs = hasVarArgs;
}
public static FuncSig of(DataType returnType, List<DataType> argumentsTypes) {
return of(returnType, false, argumentsTypes);
}
public static FuncSig of(DataType returnType, boolean hasVarArgs, List<DataType> argumentsTypes) {
return new FuncSig(returnType, hasVarArgs, argumentsTypes);
}
public static FuncSig of(DataType returnType, DataType... argumentsTypes) {
return of(returnType, false, argumentsTypes);
}
public static FuncSig of(DataType returnType, boolean hasVarArgs, DataType... argumentsTypes) {
return new FuncSig(returnType, hasVarArgs, Arrays.asList(argumentsTypes));
}
public static FuncSigBuilder ret(DataType returnType) {
return new FuncSigBuilder(returnType);
}
public static class FuncSigBuilder {
public final DataType returnType;
public FuncSigBuilder(DataType returnType) {
this.returnType = returnType;
}
public FuncSig args(DataType...argTypes) {
return FuncSig.of(returnType, false, argTypes);
}
public FuncSig varArgs(DataType...argTypes) {
return FuncSig.of(returnType, true, argTypes);
}
}
}

View File

@ -79,8 +79,8 @@ public class FunctionRegistry {
}
private void registerBuiltinFunctions(Map<String, List<FunctionBuilder>> name2Builders) {
FunctionHelper.addFunctions(name2Builders, BuiltinFunctions.INSTANCE.scalarFunctions);
FunctionHelper.addFunctions(name2Builders, BuiltinFunctions.INSTANCE.aggregateFunctions);
FunctionHelper.addFunctions(name2Builders, BuiltinScalarFunctions.INSTANCE.scalarFunctions);
FunctionHelper.addFunctions(name2Builders, BuiltinAggregateFunctions.INSTANCE.aggregateFunctions);
}
public String getCandidateHint(String name, List<FunctionBuilder> candidateBuilders) {

View File

@ -0,0 +1,115 @@
// 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.catalog;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.types.DataType;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiFunction;
public class FunctionSignature {
public final DataType returnType;
public final boolean hasVarArgs;
public final List<DataType> argumentsTypes;
public final int arity;
public FunctionSignature(DataType returnType, boolean hasVarArgs, List<DataType> argumentsTypes) {
this.returnType = Objects.requireNonNull(returnType, "returnType is not null");
this.argumentsTypes = ImmutableList.copyOf(
Objects.requireNonNull(argumentsTypes, "argumentsTypes is not null"));
this.hasVarArgs = hasVarArgs;
this.arity = argumentsTypes.size();
}
public Optional<DataType> getVarArgType() {
return hasVarArgs ? Optional.of(argumentsTypes.get(arity - 1)) : Optional.empty();
}
public DataType getArgType(int index) {
if (hasVarArgs && index >= arity) {
return argumentsTypes.get(arity - 1);
}
return argumentsTypes.get(index);
}
public FunctionSignature withReturnType(DataType returnType) {
return new FunctionSignature(returnType, hasVarArgs, argumentsTypes);
}
public FunctionSignature withArgumentTypes(boolean hasVarArgs, List<DataType> argumentsTypes) {
return new FunctionSignature(returnType, hasVarArgs, argumentsTypes);
}
/**
* change argument type by the signature's type and the corresponding argument's type
* @param arguments arguments
* @param transform param1: signature's type, param2: argument's type, return new type you want to change
* @return
*/
public FunctionSignature withArgumentTypes(List<Expression> arguments,
BiFunction<DataType, Expression, DataType> transform) {
List<DataType> newTypes = Lists.newArrayList();
for (int i = 0; i < arguments.size(); i++) {
newTypes.add(transform.apply(getArgType(i), arguments.get(i)));
}
return withArgumentTypes(hasVarArgs, newTypes);
}
public static FunctionSignature of(DataType returnType, List<DataType> argumentsTypes) {
return of(returnType, false, argumentsTypes);
}
public static FunctionSignature of(DataType returnType, boolean hasVarArgs, List<DataType> argumentsTypes) {
return new FunctionSignature(returnType, hasVarArgs, argumentsTypes);
}
public static FunctionSignature of(DataType returnType, DataType... argumentsTypes) {
return of(returnType, false, argumentsTypes);
}
public static FunctionSignature of(DataType returnType, boolean hasVarArgs, DataType... argumentsTypes) {
return new FunctionSignature(returnType, hasVarArgs, Arrays.asList(argumentsTypes));
}
public static FuncSigBuilder ret(DataType returnType) {
return new FuncSigBuilder(returnType);
}
public static class FuncSigBuilder {
public final DataType returnType;
public FuncSigBuilder(DataType returnType) {
this.returnType = returnType;
}
public FunctionSignature args(DataType...argTypes) {
return FunctionSignature.of(returnType, false, argTypes);
}
public FunctionSignature varArgs(DataType...argTypes) {
return FunctionSignature.of(returnType, true, argTypes);
}
}
}

View File

@ -27,6 +27,10 @@ import java.lang.annotation.Target;
* and tend to have bugs.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
public @interface Developing {
/**
* note string
*/
String value() default "";
}

View File

@ -28,9 +28,15 @@ import org.apache.doris.analysis.CastExpr;
import org.apache.doris.analysis.CompoundPredicate;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.FunctionCallExpr;
import org.apache.doris.analysis.FunctionName;
import org.apache.doris.analysis.FunctionParams;
import org.apache.doris.analysis.LikePredicate;
import org.apache.doris.analysis.SlotRef;
import org.apache.doris.analysis.TimestampArithmeticExpr;
import org.apache.doris.catalog.Function;
import org.apache.doris.catalog.Function.NullableMode;
import org.apache.doris.catalog.Type;
import org.apache.doris.nereids.annotation.Developing;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Alias;
import org.apache.doris.nereids.trees.expressions.And;
@ -56,10 +62,13 @@ import org.apache.doris.nereids.trees.expressions.Regexp;
import org.apache.doris.nereids.trees.expressions.SlotReference;
import org.apache.doris.nereids.trees.expressions.TimestampArithmetic;
import org.apache.doris.nereids.trees.expressions.WhenClause;
import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
import org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ScalarFunction;
import org.apache.doris.nereids.trees.expressions.literal.Literal;
import org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionVisitor;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
import java.util.ArrayList;
import java.util.List;
@ -247,20 +256,80 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
// TODO: Supports for `distinct`
@Override
public Expr visitBoundFunction(BoundFunction function, PlanTranslatorContext context) {
List<Expr> paramList = new ArrayList<>();
for (Expression expr : function.getArguments()) {
paramList.add(expr.accept(this, context));
@Developing("Generate FunctionCallExpr and Function without analyze/finalize")
public Expr visitAggregateFunction(AggregateFunction function, PlanTranslatorContext context) {
// inputTypesBeforeDissemble is used to find the origin function's input type before disassemble aggregate.
//
// For example, 'double avg(int)' will be disassembled to 'varchar avg(int)' and 'double avg(varchar)'
// which the varchar contains sum(double) and count(int).
//
// We save the origin input type 'int' for the global aggregate 'varchar avg(int)', and get it in the
// 'inputTypesBeforeDissemble' variable, so we can find the catalog function 'avg(int)' in **frontend**.
//
// Vectorized engine in backend will find the 'avg(int)' function, and forwarding to the correct global
// aggregate function 'double avg(varchar)' by FunctionCallExpr.isMergeAggFn.
Optional<List<Type>> inputTypesBeforeDissemble = function.inputTypesBeforeDissemble()
.map(types -> types.stream()
.map(DataType::toCatalogDataType)
.collect(Collectors.toList())
);
// We should change the global aggregate function's temporary input type(varchar) to the origin input type.
//
// For example: the global aggregate function expression 'avg(slotRef(type=varchar))' of the origin function
// 'avg(int)' should change to 'avg(slotRef(type=int))', because FunctionCallExpr will be converted to thrift
// format, and compute signature string by the children's type, we should pass the signature 'avg(int)' to
// **backend**. If we pass 'avg(varchar)' to backend, it will throw an exception: 'Agg Function avg is not
// implemented'.
List<Expr> catalogParams = new ArrayList<>();
for (int i = 0; i < function.arity(); i++) {
Expr catalogExpr = function.child(i).accept(this, context);
if (catalogExpr instanceof SlotRef && inputTypesBeforeDissemble.isPresent()
// count(*) in local aggregate contains empty children
// but contains one child in global aggregate: 'count(count(*))'.
// so the size of inputTypesBeforeDissemble maybe less than global aggregate param.
&& inputTypesBeforeDissemble.get().size() > i) {
SlotRef intermediateSlot = (SlotRef) catalogExpr.clone();
// change the slot type to origin input type
intermediateSlot.setType(inputTypesBeforeDissemble.get().get(i));
catalogExpr = intermediateSlot;
}
catalogParams.add(catalogExpr);
}
if (function instanceof Count) {
Count count = (Count) function;
if (count.isStar()) {
return new FunctionCallExpr(function.getName(), FunctionParams.createStarParam());
return new FunctionCallExpr(function.getName(), FunctionParams.createStarParam(),
inputTypesBeforeDissemble);
} else if (count.isDistinct()) {
return new FunctionCallExpr(function.getName(), new FunctionParams(true, paramList));
return new FunctionCallExpr(function.getName(), new FunctionParams(true, catalogParams),
inputTypesBeforeDissemble);
}
}
return new FunctionCallExpr(function.getName(), paramList);
return new FunctionCallExpr(function.getName(), new FunctionParams(false, catalogParams),
inputTypesBeforeDissemble);
}
@Override
public Expr visitScalarFunction(ScalarFunction function, PlanTranslatorContext context) {
List<Expr> arguments = function.getArguments()
.stream().map(arg -> arg.accept(this, context))
.collect(Collectors.toList());
List<Type> argTypes = function.expectedInputTypes().stream()
.map(AbstractDataType::toCatalogDataType)
.collect(Collectors.toList());
NullableMode nullableMode = function.nullable()
? NullableMode.ALWAYS_NULLABLE
: NullableMode.ALWAYS_NOT_NULLABLE;
Function catalogFunction = new Function(new FunctionName(function.getName()), argTypes,
function.getDataType().toCatalogDataType(), function.hasVarArguments(), true, nullableMode);
// create catalog FunctionCallExpr without analyze again
return new FunctionCallExpr(catalogFunction.getFunctionName(), catalogFunction,
new FunctionParams(false, arguments));
}
@Override

View File

@ -142,6 +142,7 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
public PlanFragment visitPhysicalAggregate(
PhysicalAggregate<? extends Plan> aggregate,
PlanTranslatorContext context) {
PlanFragment inputPlanFragment = aggregate.child(0).accept(this, context);
// TODO: stale planner generate aggregate tuple in a special way. tuple include 2 parts:
@ -176,7 +177,7 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
.flatMap(Set::stream)
.collect(Collectors.toList());
ArrayList<FunctionCallExpr> execAggregateFunctions = aggregateFunctionList.stream()
.map(x -> (FunctionCallExpr) ExpressionTranslator.translate(x, context))
.map(aggregateFunction -> (FunctionCallExpr) ExpressionTranslator.translate(aggregateFunction, context))
.collect(Collectors.toCollection(ArrayList::new));
// process partition list
@ -294,7 +295,7 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
SlotDescriptor slotDescriptor = oneRowTuple.getSlots().get(i);
Expr expr = legacyExprs.get(i);
slotDescriptor.setSourceExpr(expr);
slotDescriptor.setIsNullable(true); // we should set to nullable, or else BE would core
slotDescriptor.setIsNullable(legacyExprs.get(i).isNullable());
}
UnionNode unionNode = new UnionNode(context.nextPlanNodeId(), oneRowTuple.getId());

View File

@ -28,6 +28,7 @@ import org.apache.doris.nereids.trees.expressions.NamedExpression;
import org.apache.doris.nereids.trees.expressions.TimestampArithmetic;
import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
import org.apache.doris.nereids.trees.expressions.functions.FunctionBuilder;
import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateParam;
import org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionRewriter;
import org.apache.doris.nereids.trees.plans.GroupPlan;
@ -122,7 +123,9 @@ public class BindFunction implements AnalysisRuleFactory {
return new Count();
}
if (arguments.size() == 1) {
return new Count(unboundFunction.getArguments().get(0), unboundFunction.isDistinct());
boolean isGlobalAgg = true;
AggregateParam aggregateParam = new AggregateParam(unboundFunction.isDistinct(), isGlobalAgg);
return new Count(aggregateParam, unboundFunction.getArguments().get(0));
}
}
FunctionRegistry functionRegistry = env.getFunctionRegistry();

View File

@ -31,9 +31,14 @@ import org.apache.doris.nereids.trees.expressions.typecoercion.ImplicitCastInput
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
import org.apache.doris.nereids.types.coercion.CharacterType;
import org.apache.doris.nereids.types.coercion.FractionalType;
import org.apache.doris.nereids.types.coercion.IntegralType;
import org.apache.doris.nereids.types.coercion.NumericType;
import org.apache.doris.nereids.util.TypeCoercionUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import java.util.List;
import java.util.Optional;
@ -56,10 +61,13 @@ public class TypeCoercion extends AbstractExpressionRewriteRule {
@Override
public Expression visit(Expression expr, ExpressionRewriteContext ctx) {
if (expr instanceof ImplicitCastInputTypes) {
return visitImplicitCastInputTypes(expr, ctx);
} else {
return super.visit(expr, ctx);
List<AbstractDataType> expectedInputTypes = ((ImplicitCastInputTypes) expr).expectedInputTypes();
if (!expectedInputTypes.isEmpty()) {
return visitImplicitCastInputTypes(expr, expectedInputTypes, ctx);
}
}
return super.visit(expr, ctx);
}
// TODO: add other expression visitor function to do type coercion if necessary.
@ -156,37 +164,45 @@ public class TypeCoercion extends AbstractExpressionRewriteRule {
/**
* Do implicit cast for expression's children.
*/
private Expression visitImplicitCastInputTypes(Expression expr, ExpressionRewriteContext ctx) {
ImplicitCastInputTypes implicitCastInputTypes = (ImplicitCastInputTypes) expr;
List<Expression> newChildren = Lists.newArrayListWithCapacity(expr.arity());
boolean changed = false;
for (int i = 0; i < implicitCastInputTypes.expectedInputTypes().size(); i++) {
AbstractDataType expectedType = implicitCastInputTypes.expectedInputTypes().get(i);
Optional<Expression> castResult = implicitCast(expr.child(i), expectedType, ctx);
if (castResult.isPresent()) {
changed = true;
}
newChildren.add(castResult.orElse(expr.child(i)));
}
return changed ? expr.withChildren(newChildren) : expr;
private Expression visitImplicitCastInputTypes(Expression expr,
List<AbstractDataType> expectedInputTypes, ExpressionRewriteContext ctx) {
expr = expr.withChildren(child -> rewrite(child, ctx));
List<Optional<DataType>> inputImplicitCastTypes = getInputImplicitCastTypes(
expr.children(), expectedInputTypes);
return castInputs(expr, inputImplicitCastTypes);
}
/**
* Return Optional.empty() if we cannot do or do not need to do implicit cast.
*/
@Developing
private Optional<Expression> implicitCast(Expression input, AbstractDataType expected,
ExpressionRewriteContext ctx) {
Expression rewrittenInput = rewrite(input, ctx);
Optional<DataType> castDataType = TypeCoercionUtils.implicitCast(rewrittenInput.getDataType(), expected);
if (castDataType.isPresent() && !castDataType.get().equals(rewrittenInput.getDataType())) {
return Optional.of(new Cast(rewrittenInput, castDataType.get()));
} else {
if (rewrittenInput == input) {
return Optional.empty();
} else {
return Optional.of(rewrittenInput);
private List<Optional<DataType>> getInputImplicitCastTypes(
List<Expression> inputs, List<AbstractDataType> expectedTypes) {
Builder<Optional<DataType>> implicitCastTypes = ImmutableList.builder();
for (int i = 0; i < inputs.size(); i++) {
DataType argType = inputs.get(i).getDataType();
AbstractDataType expectedType = expectedTypes.get(i);
Optional<DataType> castType = TypeCoercionUtils.implicitCast(argType, expectedType);
// TODO: complete the cast logic like FunctionCallExpr.analyzeImpl
boolean legacyCastCompatible = expectedType instanceof DataType
&& !(expectedType.getClass().equals(NumericType.class))
&& !(expectedType.getClass().equals(IntegralType.class))
&& !(expectedType.getClass().equals(FractionalType.class))
&& !(expectedType.getClass().equals(CharacterType.class))
&& !argType.toCatalogDataType().matchesType(expectedType.toCatalogDataType());
if (!castType.isPresent() && legacyCastCompatible) {
castType = Optional.of((DataType) expectedType);
}
implicitCastTypes.add(castType);
}
return implicitCastTypes.build();
}
private Expression castInputs(Expression expr, List<Optional<DataType>> castTypes) {
return expr.withChildren((child, childIndex) -> {
DataType argType = child.getDataType();
Optional<DataType> castType = castTypes.get(childIndex);
if (castType.isPresent() && !castType.get().equals(argType)) {
return new Cast(child, castType.get());
} else {
return child;
}
});
}
}

View File

@ -28,6 +28,7 @@ import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunctio
import org.apache.doris.nereids.trees.plans.AggPhase;
import org.apache.doris.nereids.trees.plans.GroupPlan;
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
@ -79,38 +80,40 @@ public class AggregateDisassemble extends OneRewriteRuleFactory {
.whenNot(LogicalAggregate::isDisassembled)
.then(aggregate -> {
// used in secondDisassemble to transform local expressions into global
final Map<Expression, Expression> globalOutputSMap = Maps.newHashMap();
Pair<LogicalAggregate<LogicalAggregate<GroupPlan>>, Boolean> ret
= firstDisassemble(aggregate, globalOutputSMap);
if (!ret.second) {
return ret.first;
Map<Expression, Expression> globalOutputSMap = Maps.newHashMap();
Pair<LogicalAggregate<LogicalAggregate<GroupPlan>>, Boolean> result
= disassembleAggregateFunction(aggregate, globalOutputSMap);
LogicalAggregate<LogicalAggregate<GroupPlan>> newPlan = result.first;
boolean hasDistinct = result.second;
if (!hasDistinct) {
return newPlan;
}
return secondDisassemble(ret.first, globalOutputSMap);
return disassembleDistinct(newPlan, globalOutputSMap);
}).toRule(RuleType.AGGREGATE_DISASSEMBLE);
}
// only support distinct function with group by
// TODO: support distinct function without group by. (add second global phase)
private LogicalAggregate<LogicalAggregate<LogicalAggregate<GroupPlan>>> secondDisassemble(
private LogicalAggregate<LogicalAggregate<LogicalAggregate<GroupPlan>>> disassembleDistinct(
LogicalAggregate<LogicalAggregate<GroupPlan>> aggregate,
Map<Expression, Expression> globalOutputSMap) {
LogicalAggregate<GroupPlan> local = aggregate.child();
LogicalAggregate<GroupPlan> localDistinct = aggregate.child();
// replace expression in globalOutputExprs and globalGroupByExprs
List<NamedExpression> globalOutputExprs = local.getOutputExpressions().stream()
List<NamedExpression> globalOutputExprs = localDistinct.getOutputExpressions().stream()
.map(e -> ExpressionUtils.replace(e, globalOutputSMap))
.map(NamedExpression.class::cast)
.collect(Collectors.toList());
// generate new plan
LogicalAggregate<LogicalAggregate<GroupPlan>> globalAggregate = new LogicalAggregate<>(
local.getGroupByExpressions(),
LogicalAggregate<LogicalAggregate<GroupPlan>> globalDistinct = new LogicalAggregate<>(
localDistinct.getGroupByExpressions(),
globalOutputExprs,
Optional.of(aggregate.getGroupByExpressions()),
true,
aggregate.isNormalized(),
false,
AggPhase.GLOBAL,
local
localDistinct
);
return new LogicalAggregate<>(
aggregate.getGroupByExpressions(),
@ -119,11 +122,11 @@ public class AggregateDisassemble extends OneRewriteRuleFactory {
aggregate.isNormalized(),
true,
AggPhase.DISTINCT_LOCAL,
globalAggregate
globalDistinct
);
}
private Pair<LogicalAggregate<LogicalAggregate<GroupPlan>>, Boolean> firstDisassemble(
private Pair<LogicalAggregate<LogicalAggregate<GroupPlan>>, Boolean> disassembleAggregateFunction(
LogicalAggregate<GroupPlan> aggregate,
Map<Expression, Expression> globalOutputSMap) {
boolean hasDistinct = Boolean.FALSE;
@ -184,9 +187,25 @@ public class AggregateDisassemble extends OneRewriteRuleFactory {
}
continue;
}
NamedExpression localOutputExpr = new Alias(aggregateFunction, aggregateFunction.toSql());
Expression substitutionValue = aggregateFunction.withChildren(
Lists.newArrayList(localOutputExpr.toSlot()));
NamedExpression localOutputExpr = new Alias(aggregateFunction.withAggregateParam(
aggregateFunction.getAggregateParam()
.withDistinct(false)
.withGlobal(false)
), aggregateFunction.toSql());
List<DataType> inputTypesBeforeDissemble = aggregateFunction.children()
.stream()
.map(Expression::getDataType)
.collect(Collectors.toList());
AggregateFunction substitutionValue = aggregateFunction
// save the origin input types to the global aggregate functions
.withAggregateParam(aggregateFunction.getAggregateParam()
.withDistinct(false)
.withGlobal(true)
.withInputTypesBeforeDissemble(Optional.of(inputTypesBeforeDissemble)))
.withChildren(Lists.newArrayList(localOutputExpr.toSlot()));
inputSubstitutionMap.put(aggregateFunction, substitutionValue);
globalOutputSMap.put(aggregateFunction, substitutionValue);
localOutputExprs.add(localOutputExpr);

View File

@ -18,10 +18,13 @@
package org.apache.doris.nereids.trees;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableSet;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
/**
@ -44,6 +47,49 @@ public interface TreeNode<NODE_TYPE extends TreeNode<NODE_TYPE>> {
NODE_TYPE withChildren(List<NODE_TYPE> children);
default NODE_TYPE withChildren(Function<NODE_TYPE, NODE_TYPE> rewriter) {
return withChildren((child, index) -> rewriter.apply(child));
}
/**
* rewrite children by a rewriter
* @param rewriter consume the origin child and child index, then return the new child
* @return new tree node if any child has changed
*/
default NODE_TYPE withChildren(BiFunction<NODE_TYPE, Integer, NODE_TYPE> rewriter) {
Builder<NODE_TYPE> newChildren = ImmutableList.builderWithExpectedSize(arity());
boolean changed = false;
for (int i = 0; i < arity(); i++) {
NODE_TYPE child = child(i);
NODE_TYPE newChild = rewriter.apply(child, i);
if (child != newChild) {
changed = true;
}
newChildren.add(newChild);
}
return changed ? withChildren(newChildren.build()) : (NODE_TYPE) this;
}
/**
* bottom-up rewrite.
* @param rewriteFunction rewrite function.
* @return rewritten result.
*/
default NODE_TYPE rewriteUp(Function<NODE_TYPE, NODE_TYPE> rewriteFunction) {
Builder<NODE_TYPE> newChildren = ImmutableList.builderWithExpectedSize(arity());
boolean changed = false;
for (NODE_TYPE child : children()) {
NODE_TYPE newChild = child.rewriteUp(rewriteFunction);
if (child != newChild) {
changed = true;
}
newChildren.add(newChild);
}
NODE_TYPE rewrittenChildren = changed ? withChildren(newChildren.build()) : (NODE_TYPE) this;
return rewriteFunction.apply(rewrittenChildren);
}
/**
* Foreach treeNode. Top-down traverse implicitly.
* @param func foreach function
@ -55,6 +101,13 @@ public interface TreeNode<NODE_TYPE extends TreeNode<NODE_TYPE>> {
}
}
default void foreachUp(Consumer<TreeNode<NODE_TYPE>> func) {
for (NODE_TYPE child : children()) {
child.foreach(func);
}
func.accept(this);
}
/**
* iterate top down and test predicate if any matched. Top-down traverse implicitly.
* @param predicate predicate

View File

@ -19,9 +19,8 @@ package org.apache.doris.nereids.trees.expressions;
import org.apache.doris.nereids.analyzer.Unbound;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.exceptions.UnboundException;
import org.apache.doris.nereids.trees.AbstractTreeNode;
import org.apache.doris.nereids.trees.expressions.functions.ComputeNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExpressionTrait;
import org.apache.doris.nereids.trees.expressions.literal.Literal;
import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
import org.apache.doris.nereids.trees.expressions.shape.LeafExpression;
@ -44,7 +43,7 @@ import java.util.Set;
/**
* Abstract class for all Expression in Nereids.
*/
public abstract class Expression extends AbstractTreeNode<Expression> implements ComputeNullable {
public abstract class Expression extends AbstractTreeNode<Expression> implements ExpressionTrait {
private static final String INPUT_CHECK_ERROR_MESSAGE = "argument %d requires %s type, however '%s' is of %s type";
@ -56,14 +55,6 @@ public abstract class Expression extends AbstractTreeNode<Expression> implements
super(Optional.empty(), children);
}
public DataType getDataType() throws UnboundException {
throw new UnboundException("dataType");
}
public String toSql() throws UnboundException {
throw new UnboundException("sql");
}
public TypeCheckResult checkInputDataTypes() {
if (this instanceof ExpectsInputTypes) {
ExpectsInputTypes expectsInputTypes = (ExpectsInputTypes) this;

View File

@ -166,11 +166,15 @@ public class SlotReference extends Slot {
return this;
}
public SlotReference withDataType(DataType dataType) {
return new SlotReference(exprId, name, dataType, nullable, qualifier, column);
}
public Slot withNullable(boolean newNullable) {
if (this.nullable == newNullable) {
return this;
}
return new SlotReference(exprId, name, dataType, newNullable, qualifier);
return new SlotReference(exprId, name, dataType, newNullable, qualifier, column);
}
@Override

View File

@ -26,7 +26,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
/** BoundFunction. */
public abstract class BoundFunction extends Expression {
public abstract class BoundFunction extends Expression implements FunctionTrait {
private final String name;
public BoundFunction(String name, Expression... arguments) {
@ -34,12 +34,13 @@ public abstract class BoundFunction extends Expression {
this.name = Objects.requireNonNull(name, "name can not be null");
}
public String getName() {
return name;
public BoundFunction(String name, List<Expression> children) {
super(children);
this.name = Objects.requireNonNull(name, "name can not be null");
}
public List<Expression> getArguments() {
return children;
public String getName() {
return name;
}
@Override

View File

@ -31,6 +31,5 @@ package org.apache.doris.nereids.trees.expressions.functions;
* functions, you can find the override nullable functions which is not the above three
* interfaces.
*/
public interface ComputeNullable {
boolean nullable();
public interface ComputeNullable extends ExpressionTrait {
}

View File

@ -0,0 +1,83 @@
// 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;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.annotation.Developing;
import org.apache.doris.nereids.trees.expressions.typecoercion.ImplicitCastInputTypes;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
import java.util.List;
/**
* this class is usage to compute function's return type by the argument's type.
* in most cases, you should extends BoundFunction and implement some child interfaces of
* ComputeSignature(usually is ExplicitlyCastableSignature) and supply the signatures.
*/
@Developing
public interface ComputeSignature extends FunctionTrait, ImplicitCastInputTypes {
///// current interface's methods /////
// the signatures which you should supply as compute source
List<FunctionSignature> getSignatures();
// this method cache from the searchSignature method and implement by BoundFunction.getSignature().
// usually, it is cache version of searchSignature().
FunctionSignature getSignature();
/**
* find signature by the arguments. this method will be invoked in the BoundFunction.getSignature(),
* which BoundFunction instanceof ComputeSignature.
*
* @return the matched signature
*/
FunctionSignature searchSignature();
///// re-defined other interface's methods, so we can mixin this interfaces like a trait /////
// get function name, re-define getName method in BoundFunction
default String getName() {
return getClass().getSimpleName();
}
///// override expressions trait methods, so we can compute some properties by the signature /////
/**
* compute expectedInputTypes from the signature's argumentsTypes
* @return expectedInputTypes
*/
@Override
default List<AbstractDataType> expectedInputTypes() {
return (List) getSignature().argumentsTypes;
}
/**
* find function's return type by the signature.
* @return DataType
*/
@Override
default DataType getDataType() {
return getSignature().returnType;
}
@Override
default boolean hasVarArguments() {
return getSignature().hasVarArgs;
}
}

View File

@ -0,0 +1,57 @@
// 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;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.scalar.ScalarFunction;
import org.apache.doris.nereids.trees.expressions.literal.IntegerLikeLiteral;
import org.apache.doris.nereids.types.DateTimeV2Type;
import java.util.List;
/**
* TimeWithPrecision. fill precision to the return type.
*
* e.g. now(1) return datetime v2(1)
*/
public abstract class DateTimeWithPrecision extends ScalarFunction {
public DateTimeWithPrecision(String name, Expression... arguments) {
super(name, arguments);
}
public DateTimeWithPrecision(String name, List<Expression> arguments) {
super(name, arguments);
}
@Override
protected FunctionSignature computeSignature(FunctionSignature signature) {
if (arity() == 1 && signature.returnType instanceof DateTimeV2Type) {
// For functions in TIME_FUNCTIONS_WITH_PRECISION, we can't figure out which function should be use when
// searching in FunctionSet. So we adjust the return type by hand here.
if (child(0) instanceof IntegerLikeLiteral) {
IntegerLikeLiteral integerLikeLiteral = (IntegerLikeLiteral) child(0);
signature = signature.withReturnType(DateTimeV2Type.of(integerLikeLiteral.getIntValue()));
} else {
signature = signature.withReturnType(DateTimeV2Type.of(6));
}
}
return super.computeSignature(signature);
}
}

View File

@ -0,0 +1,22 @@
// 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;
/** DecimalSamePrecision. */
public interface DecimalSamePrecision {
}

View File

@ -0,0 +1,23 @@
// 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;
/** DecimalStddevPrecision. */
public interface DecimalStddevPrecision {
int STDDEV_DECIMAL_SCALE = 9;
}

View File

@ -0,0 +1,22 @@
// 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;
/** DecimalWiderPrecision. */
public interface DecimalWiderPrecision extends ComputeSignature {
}

View File

@ -0,0 +1,49 @@
// 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;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.catalog.Type;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
/**
* Explicitly castable signature. This class equals to 'CompareMode.IS_NONSTRICT_SUPERTYPE_OF'.
*
* Non-strict supertypes broaden the definition of supertype to accept implicit casts
* of arguments that may result in loss of precision - e.g. decimal to float.
*/
public interface ExplicitlyCastableSignature extends ComputeSignature {
static boolean isExplicitlyCastable(AbstractDataType signatureType, AbstractDataType realType) {
// TODO: copy canCastTo method to DataType
return Type.canCastTo(signatureType.toCatalogDataType(), realType.toCatalogDataType());
}
@Override
default FunctionSignature searchSignature() {
return SearchSignature.from(getSignatures(), getArguments())
// first round, use identical strategy to find signature
.orElseSearch(IdenticalSignature::isIdentical)
// second round: if not found, use nullOrIdentical strategy
.orElseSearch(NullOrIdenticalSignature::isNullOrIdentical)
// third round: if second round not found, use implicitlyCastable strategy
.orElseSearch(ImplicitlyCastableSignature::isImplicitlyCastable)
// fourth round: if third round not found, use explicitlyCastable strategy
.orElseSearch(ExplicitlyCastableSignature::isExplicitlyCastable)
.resultOrException(getName());
}
}

View File

@ -0,0 +1,49 @@
// 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;
import org.apache.doris.nereids.exceptions.UnboundException;
import org.apache.doris.nereids.trees.TreeNode;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.types.DataType;
import java.util.List;
/**
* ExpressionTrait.
*/
public interface ExpressionTrait extends TreeNode<Expression> {
boolean nullable();
default boolean notNullable() {
return !nullable();
}
default List<Expression> getArguments() {
return children();
}
default DataType getDataType() throws UnboundException {
throw new UnboundException("dataType");
}
default String toSql() throws UnboundException {
throw new UnboundException("sql");
}
}

View File

@ -0,0 +1,25 @@
// 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;
/**
* FunctionTrait.
*/
public interface FunctionTrait extends ExpressionTrait {
boolean hasVarArguments();
}

View File

@ -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.
package org.apache.doris.nereids.trees.expressions.functions;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
/**
* Identical function signature. This class equals to 'CompareMode.IS_IDENTICAL'.
*
* Two signatures are identical if the number of arguments and their types match
* exactly and signature isn't varargs.
*/
public interface IdenticalSignature extends ComputeSignature {
static boolean isIdentical(AbstractDataType signatureType, AbstractDataType realType) {
// TODO: copy matchesType to DataType
return signatureType.toCatalogDataType().matchesType(realType.toCatalogDataType());
}
@Override
default FunctionSignature searchSignature() {
return SearchSignature.from(getSignatures(), getArguments())
// first round, use identical strategy to find signature
.orElseSearch(IdenticalSignature::isIdentical)
.resultOrException(getName());
}
}

View File

@ -0,0 +1,47 @@
// 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;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.catalog.Type;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
/**
* Implicitly castable function signature. This class equals to 'CompareMode.IS_SUPERTYPE_OF'.
*
* X is a supertype of Y if Y.arg[i] can be strictly implicitly cast to X.arg[i]. If
* X has vargs, the remaining arguments of Y must be strictly implicitly castable
*/
public interface ImplicitlyCastableSignature extends ComputeSignature {
static boolean isImplicitlyCastable(AbstractDataType signatureType, AbstractDataType realType) {
// TODO: copy isImplicitlyCastable method to DataType
return Type.isImplicitlyCastable(signatureType.toCatalogDataType(), realType.toCatalogDataType(), true);
}
@Override
default FunctionSignature searchSignature() {
return SearchSignature.from(getSignatures(), getArguments())
// first round, use identical strategy to find signature
.orElseSearch(IdenticalSignature::isIdentical)
// second round: if not found, use nullOrIdentical strategy
.orElseSearch(NullOrIdenticalSignature::isNullOrIdentical)
// third round: if second round not found, use implicitlyCastable strategy
.orElseSearch(ImplicitlyCastableSignature::isImplicitlyCastable)
.resultOrException(getName());
}
}

View File

@ -0,0 +1,28 @@
// 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;
/**
* Nondeterministic functions.
*
* e.g. 'rand()', 'random()'.
*
* note: no 'uuid' function currently.
*/
public interface Nondeterministic {
}

View File

@ -0,0 +1,46 @@
// 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;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.types.NullType;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
/**
* Null or identical function signature. This class equals to 'CompareMode.IS_INDISTINGUISHABLE'.
*
* Two signatures are indistinguishable if there is no way to tell them apart
* when matching a particular instantiation. That is, their fixed arguments.
*/
public interface NullOrIdenticalSignature extends ComputeSignature {
static boolean isNullOrIdentical(AbstractDataType signatureType, AbstractDataType realType) {
// TODO: copy matchesType to DataType
return realType instanceof NullType
|| signatureType.toCatalogDataType().matchesType(realType.toCatalogDataType());
}
@Override
default FunctionSignature searchSignature() {
return SearchSignature.from(getSignatures(), getArguments())
// first round, use identical strategy to find signature
.orElseSearch(IdenticalSignature::isIdentical)
// second round: if not found, use nullOrIdentical strategy
.orElseSearch(NullOrIdenticalSignature::isNullOrIdentical)
.resultOrException(getName());
}
}

View File

@ -22,7 +22,7 @@ import org.apache.doris.nereids.trees.expressions.Expression;
import java.util.List;
/**
* nullable is true if any children is nullable, most functions is PropagateNullable.
* nullable is true if any children is nullable, most functions are PropagateNullable.
*
* e.g. `substring(null, 1)` is nullable, `substring('abc', 1)` is not nullable.
*/

View File

@ -0,0 +1,119 @@
// 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;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
import com.google.common.collect.Lists;
import java.util.List;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
/**
* SearchSignature. search candidate signature by the argument's type and predicate strategy,
* e.g. IdenticalSignature, NullOrIdenticalSignature, ImplicitlyCastableSignature, AssignCompatibleSignature.
*/
public class SearchSignature {
private final List<FunctionSignature> signatures;
private final List<Expression> arguments;
// param1: signature type
// param2: real argument type
// return: is the real argument type matches the signature type?
private List<BiFunction<AbstractDataType, AbstractDataType, Boolean>> typePredicatePerRound = Lists.newArrayList();
public SearchSignature(List<FunctionSignature> signatures, List<Expression> arguments) {
this.signatures = signatures;
this.arguments = arguments;
}
public static SearchSignature from(List<FunctionSignature> signatures, List<Expression> arguments) {
return new SearchSignature(signatures, arguments);
}
public SearchSignature orElseSearch(BiFunction<AbstractDataType, AbstractDataType, Boolean> typePredicate) {
typePredicatePerRound.add(typePredicate);
return this;
}
/**
* result.
* @return Optional functionSignature result
*/
public Optional<FunctionSignature> result() {
// search every round
for (BiFunction<AbstractDataType, AbstractDataType, Boolean> typePredicate : typePredicatePerRound) {
for (FunctionSignature signature : signatures) {
if (doMatchArity(signature, arguments) && doMatchTypes(signature, arguments, typePredicate)) {
return Optional.of(signature);
}
}
}
return Optional.empty();
}
/**
* get the result, throw can not found function if no result.
* @param functionName the function name.
* @return the result.
*/
public FunctionSignature resultOrException(String functionName) {
Optional<FunctionSignature> result = result();
if (!result.isPresent()) {
throwCanNotFoundFunctionException(functionName, arguments);
}
return result.get();
}
private boolean doMatchArity(FunctionSignature sig, List<Expression> arguments) {
int realArity = arguments.size();
if (sig.hasVarArgs && sig.arity < realArity) {
return false;
} else if (!sig.hasVarArgs && sig.arity != realArity) {
return false;
}
return true;
}
private boolean doMatchTypes(FunctionSignature sig, List<Expression> arguments,
BiFunction<AbstractDataType, AbstractDataType, Boolean> typePredicate) {
int arity = arguments.size();
for (int i = 0; i < arity; i++) {
AbstractDataType sigArgType = sig.getArgType(i);
AbstractDataType realType = arguments.get(i).getDataType();
if (!typePredicate.apply(sigArgType, realType)) {
return false;
}
}
return true;
}
private static void throwCanNotFoundFunctionException(String name, List<Expression> arguments) {
String missingSignature = name + arguments.stream()
.map(Expression::getDataType)
.map(DataType::toSql)
.collect(Collectors.joining(", ", "(", ")"));
throw new AnalysisException("Can not find the compatibility function signature: " + missingSignature);
}
}

View File

@ -1,128 +0,0 @@
// 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;
import org.apache.doris.catalog.FuncSig;
import org.apache.doris.nereids.annotation.Developing;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.typecoercion.ImplicitCastInputTypes;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.AbstractDataType;
import java.util.List;
import java.util.stream.Collectors;
/**
* you can implement this interface to simply compute dataType and expectedInputTypes by the compatibility signature.
*/
@Developing
public interface SignatureSupplier extends ImplicitCastInputTypes {
String getName();
int arity();
List<FuncSig> getSignatures();
List<Expression> getArguments();
@Override
default List<AbstractDataType> expectedInputTypes() {
int arity = arity();
List<FuncSig> candidateFunctions = getSignatures()
.stream()
.filter(s -> (s.hasVarArgs && arity >= s.argumentsTypes.size())
|| (!s.hasVarArgs && s.argumentsTypes.size() == arity))
.collect(Collectors.toList());
List<Expression> arguments = getArguments();
if (candidateFunctions.isEmpty()) {
throwCanNotFoundFunctionException(getName(), arguments);
}
for (FuncSig candidateFunction : candidateFunctions) {
if (isAssignableFrom(candidateFunction.hasVarArgs, candidateFunction.argumentsTypes,
candidateFunction.argumentsTypes)) {
return candidateFunction.argumentsTypes;
}
}
throwCanNotFoundFunctionException(getName(), arguments);
// never reach
return null;
}
/**
* find function's return data type by the signature.
* @return DataType
*/
default DataType getDataType() {
List<Expression> arguments = getArguments();
int arity = arguments.size();
for (FuncSig sig : getSignatures()) {
// check arity
if (sig.hasVarArgs && sig.argumentsTypes.size() < arity) {
continue;
} else if (!sig.hasVarArgs && sig.argumentsTypes.size() != arity) {
continue;
}
// check types
List<AbstractDataType> argTypes = arguments.stream()
.map(Expression::getDataType)
.collect(Collectors.toList());
if (isAssignableFrom(sig.hasVarArgs, sig.argumentsTypes, argTypes)) {
return sig.returnType;
}
}
throwCanNotFoundFunctionException(getName(), arguments);
// never reach
return null;
}
/**
* Check whether argument's can assign to the expected types. Currently, we just check by the
* dataType.equals(), should we support more complex type compatibility?
*
* @param isVarArgs is var args
* @param expectTypes the arguments type of function
* @param dataTypes the argument's data types
* @return true if argument's can assign to the expected types
*/
static boolean isAssignableFrom(boolean isVarArgs, List<AbstractDataType> expectTypes,
List<AbstractDataType> dataTypes) {
for (int i = 0; i < dataTypes.size(); i++) {
AbstractDataType expectType = (isVarArgs && i >= expectTypes.size())
? expectTypes.get(expectTypes.size() - 1)
: expectTypes.get(i);
AbstractDataType argumentType = dataTypes.get(i);
if (!expectType.isAssignableFrom(argumentType)) {
return false;
}
}
return true;
}
static void throwCanNotFoundFunctionException(String name, List<Expression> arguments) {
String missingSignature = name + arguments.stream()
.map(Expression::getDataType)
.map(DataType::toSql)
.collect(Collectors.joining(", ", "(", ")"));
throw new AnalysisException("Can not find the compatibility function signature: " + missingSignature);
}
}

View File

@ -22,30 +22,49 @@ import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DataType;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/**
* The function which consume arguments in lots of rows and product one value.
*/
public abstract class AggregateFunction extends BoundFunction {
private DataType intermediate;
private final boolean isDistinct;
private final AggregateParam aggregateParam;
public AggregateFunction(String name, Expression... arguments) {
super(name, arguments);
isDistinct = false;
this(name, AggregateParam.global(), arguments);
}
public AggregateFunction(String name, boolean isDistinct, Expression... arguments) {
public AggregateFunction(String name, AggregateParam aggregateParam, Expression... arguments) {
super(name, arguments);
this.isDistinct = isDistinct;
this.aggregateParam = Objects.requireNonNull(aggregateParam, "aggregateParam can not be null");
}
@Override
public abstract AggregateFunction withChildren(List<Expression> children);
public abstract DataType getFinalType();
public abstract DataType getIntermediateType();
public abstract AggregateFunction withAggregateParam(AggregateParam aggregateParam);
public boolean isDistinct() {
return isDistinct;
return aggregateParam.isDistinct;
}
public boolean isGlobal() {
return aggregateParam.isGlobal;
}
public Optional<List<DataType>> inputTypesBeforeDissemble() {
return aggregateParam.inputTypesBeforeDissemble;
}
public AggregateParam getAggregateParam() {
return aggregateParam;
}
@Override
@ -57,13 +76,14 @@ public abstract class AggregateFunction extends BoundFunction {
return false;
}
AggregateFunction that = (AggregateFunction) o;
return Objects.equals(isDistinct, that.isDistinct) && Objects.equals(intermediate, that.intermediate)
&& Objects.equals(getName(), that.getName()) && Objects.equals(children, that.children);
return Objects.equals(aggregateParam, that.aggregateParam)
&& Objects.equals(getName(), that.getName())
&& Objects.equals(children, that.children);
}
@Override
public int hashCode() {
return Objects.hash(isDistinct, intermediate, getName(), children);
return Objects.hash(aggregateParam, getName(), children);
}
@Override
@ -71,11 +91,17 @@ public abstract class AggregateFunction extends BoundFunction {
return visitor.visitAggregateFunction(this, context);
}
public DataType getIntermediate() {
return intermediate;
@Override
public boolean hasVarArguments() {
return false;
}
public void setIntermediate(DataType intermediate) {
this.intermediate = intermediate;
@Override
public final DataType getDataType() {
if (aggregateParam.isGlobal) {
return getFinalType();
} else {
return getIntermediateType();
}
}
}

View File

@ -0,0 +1,96 @@
// 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.agg;
import org.apache.doris.nereids.types.DataType;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/** AggregateParam. */
public class AggregateParam {
public final boolean isGlobal;
public final boolean isDistinct;
// When AggregateDisassemble rule disassemble the aggregate function, say double avg(int), the local
// aggregate keep the origin signature, but the global aggregate change to double avg(double).
// This behavior is difference from the legacy optimizer, because legacy optimizer keep the same signature
// between local aggregate and global aggregate. If the signatures are different, the result would wrong.
// So we use this field to record the originInputTypes, and find the catalog function by the origin input types.
public final Optional<List<DataType>> inputTypesBeforeDissemble;
public AggregateParam() {
this(false, true, Optional.empty());
}
public AggregateParam(boolean distinct) {
this(distinct, true, Optional.empty());
}
public AggregateParam(boolean isDistinct, boolean isGlobal) {
this(isDistinct, isGlobal, Optional.empty());
}
public AggregateParam(boolean isDistinct, boolean isGlobal, Optional<List<DataType>> inputTypesBeforeDissemble) {
this.isDistinct = isDistinct;
this.isGlobal = isGlobal;
this.inputTypesBeforeDissemble = Objects.requireNonNull(inputTypesBeforeDissemble,
"inputTypesBeforeDissemble can not be null");
}
public static AggregateParam distinctAndGlobal() {
return new AggregateParam(true, true, Optional.empty());
}
public static AggregateParam global() {
return new AggregateParam(false, true, Optional.empty());
}
public AggregateParam withDistinct(boolean isDistinct) {
return new AggregateParam(isDistinct, isGlobal, inputTypesBeforeDissemble);
}
public AggregateParam withGlobal(boolean isGlobal) {
return new AggregateParam(isDistinct, isGlobal, inputTypesBeforeDissemble);
}
public AggregateParam withInputTypesBeforeDissemble(Optional<List<DataType>> inputTypesBeforeDissemble) {
return new AggregateParam(isDistinct, isGlobal, inputTypesBeforeDissemble);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AggregateParam that = (AggregateParam) o;
return isDistinct == that.isDistinct
&& Objects.equals(isGlobal, that.isGlobal)
&& Objects.equals(inputTypesBeforeDissemble, that.inputTypesBeforeDissemble);
}
@Override
public int hashCode() {
return Objects.hash(isDistinct, isGlobal, inputTypesBeforeDissemble);
}
}

View File

@ -48,8 +48,12 @@ public class Avg extends AggregateFunction implements UnaryExpression, ImplicitC
super("avg", child);
}
public Avg(AggregateParam aggregateParam, Expression child) {
super("avg", aggregateParam, child);
}
@Override
public DataType getDataType() {
public DataType getFinalType() {
if (child().getDataType() instanceof DecimalType) {
return child().getDataType();
} else if (child().getDataType().isDate()) {
@ -61,25 +65,36 @@ public class Avg extends AggregateFunction implements UnaryExpression, ImplicitC
}
}
@Override
public boolean nullable() {
return child().nullable();
}
@Override
public Expression withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Avg(children.get(0));
}
// TODO: We should return a complex type: PartialAggType(bufferTypes=[Double, Int], inputType=Int)
// to denote sum(double) and count(int)
@Override
public DataType getIntermediateType() {
return VarcharType.createVarcharType(-1);
}
@Override
public boolean nullable() {
return child().nullable();
}
@Override
public Avg withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Avg(getAggregateParam(), children.get(0));
}
@Override
public Avg withAggregateParam(AggregateParam aggregateParam) {
return new Avg(aggregateParam, child());
}
@Override
public List<AbstractDataType> expectedInputTypes() {
return EXPECTED_INPUT_TYPES;
if (isGlobal() && inputTypesBeforeDissemble().isPresent()) {
return ImmutableList.of();
} else {
return EXPECTED_INPUT_TYPES;
}
}
@Override

View File

@ -39,8 +39,18 @@ public class Count extends AggregateFunction implements AlwaysNotNullable {
this.isStar = true;
}
public Count(Expression child, boolean isDistinct) {
super("count", isDistinct, child);
public Count(AggregateParam aggregateParam) {
super("count", aggregateParam);
this.isStar = true;
}
public Count(Expression child) {
super("count", child);
this.isStar = false;
}
public Count(AggregateParam aggregateParam, Expression child) {
super("count", aggregateParam, child);
this.isStar = false;
}
@ -49,22 +59,31 @@ public class Count extends AggregateFunction implements AlwaysNotNullable {
}
@Override
public DataType getDataType() {
public DataType getFinalType() {
return BigIntType.INSTANCE;
}
@Override
public Expression withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 0 || children.size() == 1);
if (children.size() == 0) {
return new Count();
}
return new Count(children.get(0), isDistinct());
public DataType getIntermediateType() {
return getFinalType();
}
@Override
public DataType getIntermediateType() {
return getDataType();
public Count withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 0 || children.size() == 1);
if (children.size() == 0) {
return this;
}
return new Count(getAggregateParam(), children.get(0));
}
@Override
public Count withAggregateParam(AggregateParam aggregateParam) {
if (arity() == 0) {
return new Count(aggregateParam);
} else {
return new Count(aggregateParam, child(0));
}
}
@Override

View File

@ -33,25 +33,34 @@ public class Max extends AggregateFunction implements UnaryExpression {
super("max", child);
}
public Max(AggregateParam aggregateParam, Expression child) {
super("max", aggregateParam, child);
}
@Override
public DataType getDataType() {
public DataType getFinalType() {
return child().getDataType();
}
@Override
public DataType getIntermediateType() {
return getFinalType();
}
@Override
public boolean nullable() {
return child().nullable();
}
@Override
public Expression withChildren(List<Expression> children) {
public Max withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Max(children.get(0));
return new Max(getAggregateParam(), children.get(0));
}
@Override
public DataType getIntermediateType() {
return getDataType();
public Max withAggregateParam(AggregateParam aggregateParam) {
return new Max(aggregateParam, child());
}
@Override

View File

@ -33,25 +33,34 @@ public class Min extends AggregateFunction implements UnaryExpression {
super("min", child);
}
public Min(AggregateParam aggregateParam, Expression child) {
super("min", aggregateParam, child);
}
@Override
public DataType getDataType() {
public DataType getFinalType() {
return child().getDataType();
}
@Override
public DataType getIntermediateType() {
return getFinalType();
}
@Override
public boolean nullable() {
return child().nullable();
}
@Override
public Expression withChildren(List<Expression> children) {
public Min withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Min(children.get(0));
return new Min(getAggregateParam(), children.get(0));
}
@Override
public DataType getIntermediateType() {
return getDataType();
public Min withAggregateParam(AggregateParam aggregateParam) {
return new Min(aggregateParam, child());
}
@Override

View File

@ -46,8 +46,12 @@ public class Sum extends AggregateFunction implements UnaryExpression, ImplicitC
super("sum", child);
}
public Sum(AggregateParam aggregateParam, Expression child) {
super("sum", aggregateParam, child);
}
@Override
public DataType getDataType() {
public DataType getFinalType() {
DataType dataType = child().getDataType();
if (dataType instanceof LargeIntType) {
return dataType;
@ -64,6 +68,11 @@ public class Sum extends AggregateFunction implements UnaryExpression, ImplicitC
}
}
@Override
public DataType getIntermediateType() {
return getFinalType();
}
@Override
public boolean nullable() {
return child().nullable();
@ -75,14 +84,14 @@ public class Sum extends AggregateFunction implements UnaryExpression, ImplicitC
}
@Override
public Expression withChildren(List<Expression> children) {
public Sum withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Sum(children.get(0));
return new Sum(getAggregateParam(), children.get(0));
}
@Override
public DataType getIntermediateType() {
return getDataType();
public Sum withAggregateParam(AggregateParam aggregateParam) {
return new Sum(aggregateParam, child());
}
@Override

View File

@ -0,0 +1,83 @@
// 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.DecimalSamePrecision;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.DecimalV2Type;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.FloatType;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.LargeIntType;
import org.apache.doris.nereids.types.SmallIntType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'abs'. This class is generated by GenerateScalarFunction.
*/
public class Abs extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable, DecimalSamePrecision {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
FunctionSignature.ret(FloatType.INSTANCE).args(FloatType.INSTANCE),
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE),
FunctionSignature.ret(LargeIntType.INSTANCE).args(BigIntType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(SmallIntType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(IntegerType.INSTANCE),
FunctionSignature.ret(SmallIntType.INSTANCE).args(TinyIntType.INSTANCE),
FunctionSignature.ret(DecimalV2Type.MAX).args(DecimalV2Type.MAX)
);
/**
* constructor with 1 argument.
*/
public Abs(Expression arg) {
super("abs", arg);
}
/**
* withChildren.
*/
@Override
public Abs withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Abs(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitAbs(this, context);
}
}

View File

@ -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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'acos'. This class is generated by GenerateScalarFunction.
*/
public class Acos extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Acos(Expression arg) {
super("acos", arg);
}
/**
* withChildren.
*/
@Override
public Acos withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Acos(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitAcos(this, context);
}
}

View File

@ -0,0 +1,89 @@
// 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.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'aes_decrypt'. This class is generated by GenerateScalarFunction.
*/
public class AesDecrypt extends ScalarFunction
implements ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(VarcharType.SYSTEM_DEFAULT,
VarcharType.SYSTEM_DEFAULT,
VarcharType.SYSTEM_DEFAULT,
VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE)
.args(StringType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public AesDecrypt(Expression arg0, Expression arg1) {
super("aes_decrypt", arg0, arg1);
}
/**
* constructor with 4 arguments.
*/
public AesDecrypt(Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
super("aes_decrypt", arg0, arg1, arg2, arg3);
}
/**
* withChildren.
*/
@Override
public AesDecrypt withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2
|| children.size() == 4);
if (children.size() == 2) {
return new AesDecrypt(children.get(0), children.get(1));
} else {
return new AesDecrypt(children.get(0), children.get(1), children.get(2), children.get(3));
}
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitAesDecrypt(this, context);
}
}

View File

@ -0,0 +1,89 @@
// 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.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'aes_encrypt'. This class is generated by GenerateScalarFunction.
*/
public class AesEncrypt extends ScalarFunction
implements ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(VarcharType.SYSTEM_DEFAULT,
VarcharType.SYSTEM_DEFAULT,
VarcharType.SYSTEM_DEFAULT,
VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE)
.args(StringType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public AesEncrypt(Expression arg0, Expression arg1) {
super("aes_encrypt", arg0, arg1);
}
/**
* constructor with 4 arguments.
*/
public AesEncrypt(Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
super("aes_encrypt", arg0, arg1, arg2, arg3);
}
/**
* withChildren.
*/
@Override
public AesEncrypt withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2
|| children.size() == 4);
if (children.size() == 2) {
return new AesEncrypt(children.get(0), children.get(1));
} else {
return new AesEncrypt(children.get(0), children.get(1), children.get(2), children.get(3));
}
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitAesEncrypt(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'append_trailing_char_if_absent'. This class is generated by GenerateScalarFunction.
*/
public class AppendTrailingCharIfAbsent extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public AppendTrailingCharIfAbsent(Expression arg0, Expression arg1) {
super("append_trailing_char_if_absent", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public AppendTrailingCharIfAbsent withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new AppendTrailingCharIfAbsent(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.visitAppendTrailingCharIfAbsent(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'ascii'. This class is generated by GenerateScalarFunction.
*/
public class Ascii extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Ascii(Expression arg) {
super("ascii", arg);
}
/**
* withChildren.
*/
@Override
public Ascii withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Ascii(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitAscii(this, context);
}
}

View File

@ -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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'asin'. This class is generated by GenerateScalarFunction.
*/
public class Asin extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Asin(Expression arg) {
super("asin", arg);
}
/**
* withChildren.
*/
@Override
public Asin withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Asin(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitAsin(this, context);
}
}

View File

@ -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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'atan'. This class is generated by GenerateScalarFunction.
*/
public class Atan extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Atan(Expression arg) {
super("atan", arg);
}
/**
* withChildren.
*/
@Override
public Atan withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Atan(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitAtan(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bin'. This class is generated by GenerateScalarFunction.
*/
public class Bin extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(BigIntType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Bin(Expression arg) {
super("bin", arg);
}
/**
* withChildren.
*/
@Override
public Bin withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Bin(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBin(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bit_length'. This class is generated by GenerateScalarFunction.
*/
public class BitLength extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitLength(Expression arg) {
super("bit_length", arg);
}
/**
* withChildren.
*/
@Override
public BitLength withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitLength(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitLength(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_and'. This class is generated by GenerateScalarFunction.
*/
public class BitmapAnd extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).varArgs(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 or more arguments.
*/
public BitmapAnd(Expression arg0, Expression arg1, Expression... varArgs) {
super("bitmap_and", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
* withChildren.
*/
@Override
public BitmapAnd withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 2);
return new BitmapAnd(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapAnd(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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_and_count'. This class is generated by GenerateScalarFunction.
*/
public class BitmapAndCount extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 or more arguments.
*/
public BitmapAndCount(Expression arg0, Expression arg1, Expression... varArgs) {
super("bitmap_and_count", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
* withChildren.
*/
@Override
public BitmapAndCount withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 2);
return new BitmapAndCount(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapAndCount(this, context);
}
}

View File

@ -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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_and_not'. This class is generated by GenerateScalarFunction.
*/
public class BitmapAndNot extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public BitmapAndNot(Expression arg0, Expression arg1) {
super("bitmap_and_not", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public BitmapAndNot withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new BitmapAndNot(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.visitBitmapAndNot(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_and_not_count'. This class is generated by GenerateScalarFunction.
*/
public class BitmapAndNotCount extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public BitmapAndNotCount(Expression arg0, Expression arg1) {
super("bitmap_and_not_count", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public BitmapAndNotCount withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new BitmapAndNotCount(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.visitBitmapAndNotCount(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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.BooleanType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_contains'. This class is generated by GenerateScalarFunction.
*/
public class BitmapContains extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).args(BitmapType.INSTANCE, BigIntType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public BitmapContains(Expression arg0, Expression arg1) {
super("bitmap_contains", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public BitmapContains withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new BitmapContains(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.visitBitmapContains(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_count'. This class is generated by GenerateScalarFunction.
*/
public class BitmapCount extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(BitmapType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitmapCount(Expression arg) {
super("bitmap_count", arg);
}
/**
* withChildren.
*/
@Override
public BitmapCount withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitmapCount(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapCount(this, context);
}
}

View File

@ -0,0 +1,57 @@
// 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.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.LeafExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_empty'. This class is generated by GenerateScalarFunction.
*/
public class BitmapEmpty extends ScalarFunction
implements LeafExpression, ExplicitlyCastableSignature, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args()
);
/**
* constructor with 0 argument.
*/
public BitmapEmpty() {
super("bitmap_empty");
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapEmpty(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_from_string'. This class is generated by GenerateScalarFunction.
*/
public class BitmapFromString extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(BitmapType.INSTANCE).args(StringType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitmapFromString(Expression arg) {
super("bitmap_from_string", arg);
}
/**
* withChildren.
*/
@Override
public BitmapFromString withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitmapFromString(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapFromString(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.BooleanType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_has_all'. This class is generated by GenerateScalarFunction.
*/
public class BitmapHasAll extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public BitmapHasAll(Expression arg0, Expression arg1) {
super("bitmap_has_all", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public BitmapHasAll withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new BitmapHasAll(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.visitBitmapHasAll(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.BooleanType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_has_any'. This class is generated by GenerateScalarFunction.
*/
public class BitmapHasAny extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public BitmapHasAny(Expression arg0, Expression arg1) {
super("bitmap_has_any", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public BitmapHasAny withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new BitmapHasAny(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.visitBitmapHasAny(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_hash'. This class is generated by GenerateScalarFunction.
*/
public class BitmapHash extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(BitmapType.INSTANCE).args(StringType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitmapHash(Expression arg) {
super("bitmap_hash", arg);
}
/**
* withChildren.
*/
@Override
public BitmapHash withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitmapHash(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapHash(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_hash64'. This class is generated by GenerateScalarFunction.
*/
public class BitmapHash64 extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(BitmapType.INSTANCE).args(StringType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitmapHash64(Expression arg) {
super("bitmap_hash64", arg);
}
/**
* withChildren.
*/
@Override
public BitmapHash64 withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitmapHash64(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapHash64(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_max'. This class is generated by GenerateScalarFunction.
*/
public class BitmapMax extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(BitmapType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitmapMax(Expression arg) {
super("bitmap_max", arg);
}
/**
* withChildren.
*/
@Override
public BitmapMax withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitmapMax(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapMax(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_min'. This class is generated by GenerateScalarFunction.
*/
public class BitmapMin extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(BitmapType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitmapMin(Expression arg) {
super("bitmap_min", arg);
}
/**
* withChildren.
*/
@Override
public BitmapMin withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitmapMin(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapMin(this, context);
}
}

View File

@ -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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_not'. This class is generated by GenerateScalarFunction.
*/
public class BitmapNot extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public BitmapNot(Expression arg0, Expression arg1) {
super("bitmap_not", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public BitmapNot withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new BitmapNot(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.visitBitmapNot(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_or'. This class is generated by GenerateScalarFunction.
*/
public class BitmapOr extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).varArgs(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 or more arguments.
*/
public BitmapOr(Expression arg0, Expression arg1, Expression... varArgs) {
super("bitmap_or", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
* withChildren.
*/
@Override
public BitmapOr withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 2);
return new BitmapOr(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapOr(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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_or_count'. This class is generated by GenerateScalarFunction.
*/
public class BitmapOrCount extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 or more arguments.
*/
public BitmapOrCount(Expression arg0, Expression arg1, Expression... varArgs) {
super("bitmap_or_count", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
* withChildren.
*/
@Override
public BitmapOrCount withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 2);
return new BitmapOrCount(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapOrCount(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.TernaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_subset_in_range'. This class is generated by GenerateScalarFunction.
*/
public class BitmapSubsetInRange extends ScalarFunction
implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE)
.args(BitmapType.INSTANCE, BigIntType.INSTANCE, BigIntType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public BitmapSubsetInRange(Expression arg0, Expression arg1, Expression arg2) {
super("bitmap_subset_in_range", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public BitmapSubsetInRange withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new BitmapSubsetInRange(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.visitBitmapSubsetInRange(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.TernaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_subset_limit'. This class is generated by GenerateScalarFunction.
*/
public class BitmapSubsetLimit extends ScalarFunction
implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE)
.args(BitmapType.INSTANCE, BigIntType.INSTANCE, BigIntType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public BitmapSubsetLimit(Expression arg0, Expression arg1, Expression arg2) {
super("bitmap_subset_limit", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public BitmapSubsetLimit withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new BitmapSubsetLimit(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.visitBitmapSubsetLimit(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.StringType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_to_string'. This class is generated by GenerateScalarFunction.
*/
public class BitmapToString extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(StringType.INSTANCE).args(BitmapType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public BitmapToString(Expression arg) {
super("bitmap_to_string", arg);
}
/**
* withChildren.
*/
@Override
public BitmapToString withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new BitmapToString(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapToString(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_xor'. This class is generated by GenerateScalarFunction.
*/
public class BitmapXor extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BitmapType.INSTANCE).varArgs(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 or more arguments.
*/
public BitmapXor(Expression arg0, Expression arg1, Expression... varArgs) {
super("bitmap_xor", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
* withChildren.
*/
@Override
public BitmapXor withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 2);
return new BitmapXor(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapXor(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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'bitmap_xor_count'. This class is generated by GenerateScalarFunction.
*/
public class BitmapXorCount extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(BitmapType.INSTANCE, BitmapType.INSTANCE)
);
/**
* constructor with 2 or more arguments.
*/
public BitmapXorCount(Expression arg0, Expression arg1, Expression... varArgs) {
super("bitmap_xor_count", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
* withChildren.
*/
@Override
public BitmapXorCount withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 2);
return new BitmapXorCount(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitBitmapXorCount(this, context);
}
}

View File

@ -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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'cbrt'. This class is generated by GenerateScalarFunction.
*/
public class Cbrt extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Cbrt(Expression arg) {
super("cbrt", arg);
}
/**
* withChildren.
*/
@Override
public Cbrt withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Cbrt(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCbrt(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'ceil'. This class is generated by GenerateScalarFunction.
*/
public class Ceil extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Ceil(Expression arg) {
super("ceil", arg);
}
/**
* withChildren.
*/
@Override
public Ceil withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Ceil(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCeil(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'ceiling'. This class is generated by GenerateScalarFunction.
*/
public class Ceiling extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Ceiling(Expression arg) {
super("ceiling", arg);
}
/**
* withChildren.
*/
@Override
public Ceiling withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Ceiling(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCeiling(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'char_length'. This class is generated by GenerateScalarFunction.
*/
public class CharLength extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public CharLength(Expression arg) {
super("char_length", arg);
}
/**
* withChildren.
*/
@Override
public CharLength withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new CharLength(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCharLength(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'character_length'. This class is generated by GenerateScalarFunction.
*/
public class CharacterLength extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public CharacterLength(Expression arg) {
super("character_length", arg);
}
/**
* withChildren.
*/
@Override
public CharacterLength withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new CharacterLength(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCharacterLength(this, context);
}
}

View File

@ -0,0 +1,111 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.BooleanType;
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.DecimalV2Type;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.FloatType;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.LargeIntType;
import org.apache.doris.nereids.types.SmallIntType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.TinyIntType;
import org.apache.doris.nereids.types.VarcharType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'coalesce'. This class is generated by GenerateScalarFunction.
*/
public class Coalesce extends ScalarFunction
implements ExplicitlyCastableSignature {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).varArgs(BooleanType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).varArgs(TinyIntType.INSTANCE),
FunctionSignature.ret(SmallIntType.INSTANCE).varArgs(SmallIntType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).varArgs(IntegerType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(BigIntType.INSTANCE),
FunctionSignature.ret(LargeIntType.INSTANCE).varArgs(LargeIntType.INSTANCE),
FunctionSignature.ret(FloatType.INSTANCE).varArgs(FloatType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).varArgs(DoubleType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).varArgs(DateTimeType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).varArgs(DateType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).varArgs(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).varArgs(DateV2Type.INSTANCE),
FunctionSignature.ret(DecimalV2Type.MAX).varArgs(DecimalV2Type.MAX),
FunctionSignature.ret(BitmapType.INSTANCE).varArgs(BitmapType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).varArgs(StringType.INSTANCE)
);
/**
* constructor with 1 or more arguments.
*/
public Coalesce(Expression arg, Expression... varArgs) {
super("coalesce", ExpressionUtils.mergeArguments(arg, varArgs));
}
/**
* custom compute nullable.
*/
@Override
public boolean nullable() {
for (Expression argument : children) {
if (!argument.nullable()) {
return false;
}
}
return true;
}
/**
* withChildren.
*/
@Override
public Coalesce withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 1);
return new Coalesce(children.get(0),
children.subList(1, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCoalesce(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'concat'. This class is generated by GenerateScalarFunction.
*/
public class Concat extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).varArgs(StringType.INSTANCE)
);
/**
* constructor with 1 or more arguments.
*/
public Concat(Expression arg, Expression... varArgs) {
super("concat", ExpressionUtils.mergeArguments(arg, varArgs));
}
/**
* withChildren.
*/
@Override
public Concat withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 1);
return new Concat(children.get(0),
children.subList(1, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitConcat(this, context);
}
}

View File

@ -0,0 +1,79 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.VarcharType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'concat_ws'. This class is generated by GenerateScalarFunction.
*/
public class ConcatWs extends ScalarFunction
implements ExplicitlyCastableSignature {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.varArgs(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).varArgs(StringType.INSTANCE, StringType.INSTANCE)
);
/**
* constructor with 2 or more arguments.
*/
public ConcatWs(Expression arg0, Expression arg1, Expression... varArgs) {
super("concat_ws", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
* custom compute nullable.
*/
@Override
public boolean nullable() {
return child(0).nullable();
}
/**
* withChildren.
*/
@Override
public ConcatWs withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() >= 2);
return new ConcatWs(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitConcatWs(this, context);
}
}

View File

@ -0,0 +1,76 @@
// 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.TernaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.TinyIntType;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'conv'. This class is generated by GenerateScalarFunction.
*/
public class Conv extends ScalarFunction
implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(BigIntType.INSTANCE, TinyIntType.INSTANCE, TinyIntType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(VarcharType.SYSTEM_DEFAULT, TinyIntType.INSTANCE, TinyIntType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(StringType.INSTANCE, TinyIntType.INSTANCE, TinyIntType.INSTANCE)
);
/**
* constructor with 3 arguments.
*/
public Conv(Expression arg0, Expression arg1, Expression arg2) {
super("conv", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public Conv withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new Conv(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.visitConv(this, context);
}
}

View File

@ -0,0 +1,76 @@
// 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.TernaryExpression;
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.DateV2Type;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'convert_tz'. This class is generated by GenerateScalarFunction.
*/
public class ConvertTz extends ScalarFunction
implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT)
);
/**
* constructor with 3 arguments.
*/
public ConvertTz(Expression arg0, Expression arg1, Expression arg2) {
super("convert_tz", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public ConvertTz withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3);
return new ConvertTz(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.visitConvertTz(this, context);
}
}

View File

@ -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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'cos'. This class is generated by GenerateScalarFunction.
*/
public class Cos extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Cos(Expression arg) {
super("cos", arg);
}
/**
* withChildren.
*/
@Override
public Cos withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Cos(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCos(this, context);
}
}

View File

@ -0,0 +1,58 @@
// 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.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.Nondeterministic;
import org.apache.doris.nereids.trees.expressions.shape.LeafExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateType;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'current_date'. This class is generated by GenerateScalarFunction.
*/
public class CurrentDate extends ScalarFunction
implements LeafExpression, ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateType.INSTANCE).args()
);
/**
* constructor with 0 argument.
*/
public CurrentDate() {
super("current_date");
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCurrentDate(this, context);
}
}

View File

@ -0,0 +1,58 @@
// 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.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.Nondeterministic;
import org.apache.doris.nereids.trees.expressions.shape.LeafExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.TimeType;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'current_time'. This class is generated by GenerateScalarFunction.
*/
public class CurrentTime extends ScalarFunction
implements LeafExpression, ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(TimeType.INSTANCE).args()
);
/**
* constructor with 0 argument.
*/
public CurrentTime() {
super("current_time");
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCurrentTime(this, context);
}
}

View File

@ -0,0 +1,84 @@
// 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.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.DateTimeWithPrecision;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.Nondeterministic;
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.IntegerType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'current_timestamp'. This class is generated by GenerateScalarFunction.
*/
public class CurrentTimestamp extends DateTimeWithPrecision
implements ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE)
);
/**
* constructor with 0 argument.
*/
public CurrentTimestamp() {
super("current_timestamp");
}
/**
* constructor with 1 argument.
*/
public CurrentTimestamp(Expression arg) {
super("current_timestamp", arg);
}
/**
* withChildren.
*/
@Override
public CurrentTimestamp withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 0
|| children.size() == 1);
if (children.isEmpty() && arity() == 0) {
return this;
} else {
return new CurrentTimestamp(children.get(0));
}
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCurrentTimestamp(this, context);
}
}

View File

@ -0,0 +1,58 @@
// 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.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.Nondeterministic;
import org.apache.doris.nereids.trees.expressions.shape.LeafExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.TimeType;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'curtime'. This class is generated by GenerateScalarFunction.
*/
public class Curtime extends ScalarFunction
implements LeafExpression, ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(TimeType.INSTANCE).args()
);
/**
* constructor with 0 argument.
*/
public Curtime() {
super("curtime");
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitCurtime(this, context);
}
}

View File

@ -0,0 +1,72 @@
// 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.UnaryExpression;
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 com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'date'. This class is generated by GenerateScalarFunction.
*/
public class Date extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Date(Expression arg) {
super("date", arg);
}
/**
* withChildren.
*/
@Override
public Date withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Date(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDate(this, context);
}
}

View File

@ -0,0 +1,77 @@
// 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.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 'datediff'. This class is generated by GenerateScalarFunction.
*/
public class DateDiff extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public DateDiff(Expression arg0, Expression arg1) {
super("datediff", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public DateDiff withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new DateDiff(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.visitDateDiff(this, context);
}
}

View File

@ -0,0 +1,75 @@
// 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.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'date_format'. This class is generated by GenerateScalarFunction.
*/
public class DateFormat extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeType.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateType.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT)
);
/**
* constructor with 2 arguments.
*/
public DateFormat(Expression arg0, Expression arg1) {
super("date_format", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public DateFormat withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new DateFormat(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.visitDateFormat(this, context);
}
}

View File

@ -0,0 +1,71 @@
// 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.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'date_trunc'. This class is generated by GenerateScalarFunction.
*/
public class DateTrunc extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT)
);
/**
* constructor with 2 arguments.
*/
public DateTrunc(Expression arg0, Expression arg1) {
super("date_trunc", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public DateTrunc withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new DateTrunc(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.visitDateTrunc(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'datev2'. This class is generated by GenerateScalarFunction.
*/
public class DateV2 extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public DateV2(Expression arg) {
super("datev2", arg);
}
/**
* withChildren.
*/
@Override
public DateV2 withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new DateV2(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDateV2(this, context);
}
}

View File

@ -0,0 +1,73 @@
// 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.UnaryExpression;
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.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 'day'. This class is generated by GenerateScalarFunction.
*/
public class Day extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Day(Expression arg) {
super("day", arg);
}
/**
* withChildren.
*/
@Override
public Day withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Day(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDay(this, context);
}
}

View File

@ -0,0 +1,106 @@
// 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.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
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 'day_ceil'. This class is generated by GenerateScalarFunction.
*/
public class DayCeil extends ScalarFunction
implements ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public DayCeil(Expression arg) {
super("day_ceil", arg);
}
/**
* constructor with 2 arguments.
*/
public DayCeil(Expression arg0, Expression arg1) {
super("day_ceil", arg0, arg1);
}
/**
* constructor with 3 arguments.
*/
public DayCeil(Expression arg0, Expression arg1, Expression arg2) {
super("day_ceil", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public DayCeil withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1
|| children.size() == 2
|| children.size() == 3);
if (children.size() == 1) {
return new DayCeil(children.get(0));
} else if (children.size() == 2) {
return new DayCeil(children.get(0), children.get(1));
} else {
return new DayCeil(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.visitDayCeil(this, context);
}
}

View File

@ -0,0 +1,106 @@
// 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.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
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 'day_floor'. This class is generated by GenerateScalarFunction.
*/
public class DayFloor extends ScalarFunction
implements ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public DayFloor(Expression arg) {
super("day_floor", arg);
}
/**
* constructor with 2 arguments.
*/
public DayFloor(Expression arg0, Expression arg1) {
super("day_floor", arg0, arg1);
}
/**
* constructor with 3 arguments.
*/
public DayFloor(Expression arg0, Expression arg1, Expression arg2) {
super("day_floor", arg0, arg1, arg2);
}
/**
* withChildren.
*/
@Override
public DayFloor withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1
|| children.size() == 2
|| children.size() == 3);
if (children.size() == 1) {
return new DayFloor(children.get(0));
} else if (children.size() == 2) {
return new DayFloor(children.get(0), children.get(1));
} else {
return new DayFloor(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.visitDayFloor(this, context);
}
}

View File

@ -0,0 +1,73 @@
// 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.UnaryExpression;
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.DateV2Type;
import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'dayname'. This class is generated by GenerateScalarFunction.
*/
public class DayName extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public DayName(Expression arg) {
super("dayname", arg);
}
/**
* withChildren.
*/
@Override
public DayName withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new DayName(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDayName(this, context);
}
}

View File

@ -0,0 +1,73 @@
// 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.UnaryExpression;
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.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 'dayofmonth'. This class is generated by GenerateScalarFunction.
*/
public class DayOfMonth extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public DayOfMonth(Expression arg) {
super("dayofmonth", arg);
}
/**
* withChildren.
*/
@Override
public DayOfMonth withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new DayOfMonth(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDayOfMonth(this, context);
}
}

View File

@ -0,0 +1,73 @@
// 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.UnaryExpression;
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.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 'dayofweek'. This class is generated by GenerateScalarFunction.
*/
public class DayOfWeek extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public DayOfWeek(Expression arg) {
super("dayofweek", arg);
}
/**
* withChildren.
*/
@Override
public DayOfWeek withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new DayOfWeek(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDayOfWeek(this, context);
}
}

View File

@ -0,0 +1,73 @@
// 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.UnaryExpression;
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.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 'dayofyear'. This class is generated by GenerateScalarFunction.
*/
public class DayOfYear extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public DayOfYear(Expression arg) {
super("dayofyear", arg);
}
/**
* withChildren.
*/
@Override
public DayOfYear withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new DayOfYear(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDayOfYear(this, context);
}
}

View File

@ -0,0 +1,79 @@
// 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.BigIntType;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'days_diff'. This class is generated by GenerateScalarFunction.
*/
public class DaysDiff extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
);
/**
* constructor with 2 arguments.
*/
public DaysDiff(Expression arg0, Expression arg1) {
super("days_diff", arg0, arg1);
}
/**
* withChildren.
*/
@Override
public DaysDiff withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new DaysDiff(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.visitDaysDiff(this, context);
}
}

View File

@ -0,0 +1,69 @@
// 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.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.DoubleType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'dceil'. This class is generated by GenerateScalarFunction.
*/
public class Dceil extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE)
);
/**
* constructor with 1 argument.
*/
public Dceil(Expression arg) {
super("dceil", arg);
}
/**
* withChildren.
*/
@Override
public Dceil withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
return new Dceil(children.get(0));
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDceil(this, context);
}
}

Some files were not shown because too many files have changed in this diff Show More