From 6eea855e78a9da795cf0d960136176f6fe7609fe Mon Sep 17 00:00:00 2001 From: 924060929 <924060929@qq.com> Date: Wed, 2 Nov 2022 18:01:08 +0800 Subject: [PATCH] [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. --- .../doris/analysis/FunctionCallExpr.java | 66 +- ...ns.java => BuiltinAggregateFunctions.java} | 19 +- .../doris/catalog/BuiltinScalarFunctions.java | 511 +++++++ .../org/apache/doris/catalog/FuncSig.java | 76 -- .../doris/catalog/FunctionRegistry.java | 4 +- .../doris/catalog/FunctionSignature.java | 115 ++ .../doris/nereids/annotation/Developing.java | 6 +- .../glue/translator/ExpressionTranslator.java | 85 +- .../translator/PhysicalPlanTranslator.java | 5 +- .../nereids/rules/analysis/BindFunction.java | 5 +- .../rewrite/rules/TypeCoercion.java | 80 +- .../rules/rewrite/AggregateDisassemble.java | 53 +- .../apache/doris/nereids/trees/TreeNode.java | 53 + .../nereids/trees/expressions/Expression.java | 13 +- .../trees/expressions/SlotReference.java | 6 +- .../expressions/functions/BoundFunction.java | 11 +- .../functions/ComputeNullable.java | 3 +- .../functions/ComputeSignature.java | 83 ++ .../functions/DateTimeWithPrecision.java | 57 + .../functions/DecimalSamePrecision.java | 22 + .../functions/DecimalStddevPrecision.java | 23 + .../functions/DecimalWiderPrecision.java | 22 + .../ExplicitlyCastableSignature.java | 49 + .../functions/ExpressionTrait.java | 49 + .../expressions/functions/FunctionTrait.java | 25 + .../functions/IdenticalSignature.java | 42 + .../ImplicitlyCastableSignature.java | 47 + .../functions/Nondeterministic.java | 28 + .../functions/NullOrIdenticalSignature.java | 46 + .../functions/PropagateNullable.java | 2 +- .../functions/SearchSignature.java | 119 ++ .../functions/SignatureSupplier.java | 128 -- .../functions/agg/AggregateFunction.java | 54 +- .../functions/agg/AggregateParam.java | 96 ++ .../trees/expressions/functions/agg/Avg.java | 41 +- .../expressions/functions/agg/Count.java | 41 +- .../trees/expressions/functions/agg/Max.java | 19 +- .../trees/expressions/functions/agg/Min.java | 19 +- .../trees/expressions/functions/agg/Sum.java | 19 +- .../expressions/functions/scalar/Abs.java | 83 ++ .../expressions/functions/scalar/Acos.java | 68 + .../functions/scalar/AesDecrypt.java | 89 ++ .../functions/scalar/AesEncrypt.java | 89 ++ .../scalar/AppendTrailingCharIfAbsent.java | 71 + .../expressions/functions/scalar/Ascii.java | 71 + .../expressions/functions/scalar/Asin.java | 68 + .../expressions/functions/scalar/Atan.java | 68 + .../expressions/functions/scalar/Bin.java | 69 + .../functions/scalar/BitLength.java | 71 + .../functions/scalar/BitmapAnd.java | 69 + .../functions/scalar/BitmapAndCount.java | 70 + .../functions/scalar/BitmapAndNot.java | 68 + .../functions/scalar/BitmapAndNotCount.java | 69 + .../functions/scalar/BitmapContains.java | 70 + .../functions/scalar/BitmapCount.java | 69 + .../functions/scalar/BitmapEmpty.java | 57 + .../functions/scalar/BitmapFromString.java | 71 + .../functions/scalar/BitmapHasAll.java | 69 + .../functions/scalar/BitmapHasAny.java | 69 + .../functions/scalar/BitmapHash.java | 71 + .../functions/scalar/BitmapHash64.java | 71 + .../functions/scalar/BitmapMax.java | 69 + .../functions/scalar/BitmapMin.java | 69 + .../functions/scalar/BitmapNot.java | 68 + .../functions/scalar/BitmapOr.java | 69 + .../functions/scalar/BitmapOrCount.java | 70 + .../functions/scalar/BitmapSubsetInRange.java | 70 + .../functions/scalar/BitmapSubsetLimit.java | 70 + .../functions/scalar/BitmapToString.java | 69 + .../functions/scalar/BitmapXor.java | 69 + .../functions/scalar/BitmapXorCount.java | 70 + .../expressions/functions/scalar/Cbrt.java | 68 + .../expressions/functions/scalar/Ceil.java | 69 + .../expressions/functions/scalar/Ceiling.java | 69 + .../functions/scalar/CharLength.java | 71 + .../functions/scalar/CharacterLength.java | 71 + .../functions/scalar/Coalesce.java | 111 ++ .../expressions/functions/scalar/Concat.java | 71 + .../functions/scalar/ConcatWs.java | 79 ++ .../expressions/functions/scalar/Conv.java | 76 ++ .../functions/scalar/ConvertTz.java | 76 ++ .../expressions/functions/scalar/Cos.java | 68 + .../functions/scalar/CurrentDate.java | 58 + .../functions/scalar/CurrentTime.java | 58 + .../functions/scalar/CurrentTimestamp.java | 84 ++ .../expressions/functions/scalar/Curtime.java | 58 + .../expressions/functions/scalar/Date.java | 72 + .../functions/scalar/DateDiff.java | 77 ++ .../functions/scalar/DateFormat.java | 75 + .../functions/scalar/DateTrunc.java | 71 + .../expressions/functions/scalar/DateV2.java | 69 + .../expressions/functions/scalar/Day.java | 73 + .../expressions/functions/scalar/DayCeil.java | 106 ++ .../functions/scalar/DayFloor.java | 106 ++ .../expressions/functions/scalar/DayName.java | 73 + .../functions/scalar/DayOfMonth.java | 73 + .../functions/scalar/DayOfWeek.java | 73 + .../functions/scalar/DayOfYear.java | 73 + .../functions/scalar/DaysDiff.java | 79 ++ .../expressions/functions/scalar/Dceil.java | 69 + .../expressions/functions/scalar/Degrees.java | 68 + .../expressions/functions/scalar/Dexp.java | 68 + .../expressions/functions/scalar/Dfloor.java | 69 + .../expressions/functions/scalar/Dlog1.java | 68 + .../expressions/functions/scalar/Dlog10.java | 68 + .../expressions/functions/scalar/Dpow.java | 68 + .../expressions/functions/scalar/Dround.java | 82 ++ .../expressions/functions/scalar/Dsqrt.java | 68 + .../trees/expressions/functions/scalar/E.java | 57 + .../expressions/functions/scalar/Elt.java | 72 + .../functions/scalar/EndsWith.java | 71 + .../expressions/functions/scalar/EsQuery.java | 69 + .../expressions/functions/scalar/Exp.java | 68 + .../functions/scalar/ExtractUrlParameter.java | 69 + .../functions/scalar/FindInSet.java | 71 + .../expressions/functions/scalar/Floor.java | 69 + .../expressions/functions/scalar/Fmod.java | 70 + .../expressions/functions/scalar/Fpow.java | 68 + .../functions/scalar/FromBase64.java | 70 + .../functions/scalar/FromDays.java | 69 + .../functions/scalar/FromUnixtime.java | 83 ++ .../functions/scalar/GetJsonDouble.java | 71 + .../functions/scalar/GetJsonInt.java | 71 + .../functions/scalar/GetJsonString.java | 71 + .../functions/scalar/Greatest.java | 91 ++ .../expressions/functions/scalar/Hex.java | 72 + .../functions/scalar/HllCardinality.java | 69 + .../functions/scalar/HllEmpty.java | 57 + .../expressions/functions/scalar/HllHash.java | 71 + .../expressions/functions/scalar/Hour.java | 73 + .../functions/scalar/HourCeil.java | 106 ++ .../functions/scalar/HourFloor.java | 106 ++ .../functions/scalar/HoursDiff.java | 79 ++ .../expressions/functions/scalar/If.java | 146 ++ .../expressions/functions/scalar/Initcap.java | 68 + .../expressions/functions/scalar/Instr.java | 71 + .../functions/scalar/JsonArray.java | 69 + .../functions/scalar/JsonObject.java | 69 + .../functions/scalar/JsonQuote.java | 68 + .../functions/scalar/JsonbExistsPath.java | 72 + .../functions/scalar/JsonbExtract.java | 71 + .../functions/scalar/JsonbExtractBigint.java | 72 + .../functions/scalar/JsonbExtractBool.java | 72 + .../functions/scalar/JsonbExtractDouble.java | 72 + .../functions/scalar/JsonbExtractInt.java | 72 + .../functions/scalar/JsonbExtractIsnull.java | 72 + .../functions/scalar/JsonbExtractString.java | 71 + .../functions/scalar/JsonbParse.java | 69 + .../scalar/JsonbParseErrorToInvalid.java | 69 + .../scalar/JsonbParseErrorToNull.java | 69 + .../scalar/JsonbParseErrorToValue.java | 69 + .../functions/scalar/JsonbParseNotnull.java | 69 + .../JsonbParseNotnullErrorToInvalid.java | 69 + .../scalar/JsonbParseNotnullErrorToValue.java | 69 + .../functions/scalar/JsonbParseNullable.java | 69 + .../JsonbParseNullableErrorToInvalid.java | 69 + .../scalar/JsonbParseNullableErrorToNull.java | 69 + .../JsonbParseNullableErrorToValue.java | 69 + .../functions/scalar/JsonbType.java | 69 + .../expressions/functions/scalar/Least.java | 89 ++ .../expressions/functions/scalar/Left.java | 71 + .../expressions/functions/scalar/Length.java | 71 + .../expressions/functions/scalar/Ln.java | 68 + .../functions/scalar/LocalTime.java | 84 ++ .../functions/scalar/LocalTimestamp.java | 84 ++ .../expressions/functions/scalar/Locate.java | 86 ++ .../expressions/functions/scalar/Log.java | 68 + .../expressions/functions/scalar/Log10.java | 68 + .../expressions/functions/scalar/Log2.java | 68 + .../expressions/functions/scalar/Lower.java | 70 + .../expressions/functions/scalar/Lpad.java | 73 + .../expressions/functions/scalar/Ltrim.java | 70 + .../functions/scalar/MakeDate.java | 69 + .../expressions/functions/scalar/Md5.java | 70 + .../expressions/functions/scalar/Md5Sum.java | 71 + .../expressions/functions/scalar/Minute.java | 73 + .../functions/scalar/MinuteCeil.java | 106 ++ .../functions/scalar/MinuteFloor.java | 106 ++ .../functions/scalar/MinutesDiff.java | 79 ++ .../functions/scalar/MoneyFormat.java | 75 + .../expressions/functions/scalar/Month.java | 73 + .../functions/scalar/MonthCeil.java | 106 ++ .../functions/scalar/MonthFloor.java | 106 ++ .../functions/scalar/MonthName.java | 73 + .../functions/scalar/MonthsDiff.java | 79 ++ .../functions/scalar/MurmurHash332.java | 72 + .../functions/scalar/MurmurHash364.java | 72 + .../functions/scalar/Negative.java | 73 + .../functions/scalar/NotNullOrEmpty.java | 71 + .../expressions/functions/scalar/Now.java | 84 ++ .../expressions/functions/scalar/NullIf.java | 97 ++ .../functions/scalar/NullOrEmpty.java | 71 + .../expressions/functions/scalar/Nvl.java | 109 ++ .../functions/scalar/ParseUrl.java | 86 ++ .../expressions/functions/scalar/Pi.java | 57 + .../expressions/functions/scalar/Pmod.java | 70 + .../functions/scalar/Positive.java | 73 + .../expressions/functions/scalar/Pow.java | 68 + .../expressions/functions/scalar/Power.java | 68 + .../functions/scalar/QuantilePercent.java | 70 + .../expressions/functions/scalar/Quarter.java | 73 + .../expressions/functions/scalar/Radians.java | 68 + .../expressions/functions/scalar/Random.java | 92 ++ .../functions/scalar/RegexpExtract.java | 73 + .../functions/scalar/RegexpReplace.java | 72 + .../expressions/functions/scalar/Repeat.java | 71 + .../expressions/functions/scalar/Replace.java | 72 + .../expressions/functions/scalar/Reverse.java | 70 + .../expressions/functions/scalar/Right.java | 71 + .../expressions/functions/scalar/Round.java | 82 ++ .../expressions/functions/scalar/Rpad.java | 73 + .../expressions/functions/scalar/Rtrim.java | 70 + .../functions/scalar/ScalarFunction.java | 185 ++- .../expressions/functions/scalar/Second.java | 73 + .../functions/scalar/SecondCeil.java | 106 ++ .../functions/scalar/SecondFloor.java | 106 ++ .../functions/scalar/SecondsDiff.java | 79 ++ .../expressions/functions/scalar/Sign.java | 69 + .../expressions/functions/scalar/Sin.java | 68 + .../expressions/functions/scalar/Sleep.java | 69 + .../expressions/functions/scalar/Sm3.java | 70 + .../expressions/functions/scalar/Sm3sum.java | 71 + .../functions/scalar/Sm4Decrypt.java | 89 ++ .../functions/scalar/Sm4Encrypt.java | 89 ++ .../expressions/functions/scalar/Space.java | 69 + .../functions/scalar/SplitPart.java | 73 + .../expressions/functions/scalar/Sqrt.java | 68 + .../functions/scalar/StAstext.java | 70 + .../expressions/functions/scalar/StAswkt.java | 70 + .../functions/scalar/StCircle.java | 70 + .../functions/scalar/StContains.java | 69 + .../functions/scalar/StDistanceSphere.java | 68 + .../functions/scalar/StGeometryfromtext.java | 70 + .../functions/scalar/StGeomfromtext.java | 70 + .../functions/scalar/StLinefromtext.java | 70 + .../scalar/StLinestringfromtext.java | 70 + .../expressions/functions/scalar/StPoint.java | 69 + .../functions/scalar/StPolyfromtext.java | 70 + .../functions/scalar/StPolygon.java | 70 + .../functions/scalar/StPolygonfromtext.java | 70 + .../expressions/functions/scalar/StX.java | 71 + .../expressions/functions/scalar/StY.java | 71 + .../functions/scalar/StartsWith.java | 71 + .../expressions/functions/scalar/StrLeft.java | 71 + .../functions/scalar/StrRight.java | 71 + .../functions/scalar/StrToDate.java | 116 ++ .../functions/scalar/SubBitmap.java | 70 + .../functions/scalar/Substring.java | 70 +- .../expressions/functions/scalar/Tan.java | 68 + .../functions/scalar/TimeDiff.java | 78 ++ .../functions/scalar/Timestamp.java | 70 + .../functions/scalar/ToBase64.java | 68 + .../functions/scalar/ToBitmap.java | 71 + .../functions/scalar/ToBitmapWithCheck.java | 71 + .../expressions/functions/scalar/ToDate.java | 72 + .../functions/scalar/ToDateV2.java | 69 + .../expressions/functions/scalar/ToDays.java | 71 + .../functions/scalar/ToQuantileState.java | 70 + .../expressions/functions/scalar/Trim.java | 70 + .../functions/scalar/Truncate.java | 69 + .../expressions/functions/scalar/Unhex.java | 70 + .../functions/scalar/UnixTimestamp.java | 108 ++ .../expressions/functions/scalar/Upper.java | 70 + .../functions/scalar/UtcTimestamp.java | 58 + .../expressions/functions/scalar/Version.java | 57 + .../expressions/functions/scalar/Week.java | 87 ++ .../functions/scalar/WeekCeil.java | 106 ++ .../functions/scalar/WeekFloor.java | 106 ++ .../functions/scalar/WeekOfYear.java | 46 +- .../expressions/functions/scalar/Weekday.java | 73 + .../functions/scalar/WeeksDiff.java | 79 ++ .../expressions/functions/scalar/Year.java | 48 +- .../functions/scalar/YearCeil.java | 106 ++ .../functions/scalar/YearFloor.java | 106 ++ .../functions/scalar/YearWeek.java | 87 ++ .../functions/scalar/YearsDiff.java | 79 ++ .../expressions/literal/BigIntLiteral.java | 7 +- .../expressions/literal/CharLiteral.java | 12 +- .../expressions/literal/DateLiteral.java | 3 +- .../literal/IntegerLikeLiteral.java | 38 + .../expressions/literal/IntegerLiteral.java | 7 +- .../expressions/literal/LargeIntLiteral.java | 7 +- .../trees/expressions/literal/Literal.java | 14 +- .../expressions/literal/SmallIntLiteral.java | 7 +- .../literal/StringLikeLiteral.java | 34 + .../expressions/literal/StringLiteral.java | 4 +- .../expressions/literal/TinyIntLiteral.java | 12 +- .../expressions/literal/VarcharLiteral.java | 17 +- .../visitor/AggregateFunctionVisitor.java | 50 + .../visitor/ExpressionVisitor.java | 70 +- .../visitor/ScalarFunctionVisitor.java | 1206 +++++++++++++++++ .../trees/plans/logical/LogicalAggregate.java | 7 +- .../apache/doris/nereids/types/ArrayType.java | 26 +- .../doris/nereids/types/BigIntType.java | 3 +- .../doris/nereids/types/BitmapType.java | 3 +- .../apache/doris/nereids/types/CharType.java | 6 +- .../apache/doris/nereids/types/DataType.java | 210 ++- .../doris/nereids/types/DateTimeV2Type.java | 25 +- .../doris/nereids/types/DateV2Type.java | 2 +- .../doris/nereids/types/DecimalType.java | 3 +- .../doris/nereids/types/DecimalV2Type.java | 61 +- .../doris/nereids/types/DecimalV3Type.java | 187 +++ .../doris/nereids/types/DoubleType.java | 3 +- .../apache/doris/nereids/types/FloatType.java | 3 +- .../apache/doris/nereids/types/HllType.java | 5 +- .../doris/nereids/types/IntegerType.java | 3 +- .../apache/doris/nereids/types/JsonType.java | 71 + .../doris/nereids/types/LargeIntType.java | 3 +- .../apache/doris/nereids/types/MapType.java | 71 + .../nereids/types/QuantileStateType.java | 3 +- .../doris/nereids/types/SmallIntType.java | 3 +- .../doris/nereids/types/StringType.java | 3 +- .../doris/nereids/types/StructType.java | 71 + .../apache/doris/nereids/types/TextType.java | 9 +- .../doris/nereids/types/TimeV2Type.java | 2 +- .../doris/nereids/types/TinyIntType.java | 3 +- .../doris/nereids/types/VarcharType.java | 6 +- .../types/coercion/AbstractDataType.java | 11 +- .../nereids/types/coercion/AnyDataType.java | 9 +- .../nereids/types/coercion/CharacterType.java | 2 +- .../types/coercion/FractionalType.java | 2 +- .../nereids/types/coercion/IntegralType.java | 2 +- .../nereids/types/coercion/NumericType.java | 2 +- .../types/coercion/TypeCollection.java | 9 +- .../nereids/util/ResponsibilityChain.java | 97 ++ .../org/apache/doris/qe/StmtExecutor.java | 9 +- .../nereids/parser/HavingClauseTest.java | 4 +- .../rules/analysis/FunctionRegistryTest.java | 10 + .../analysis/GenerateScalarFunction.java | 983 +++++++++++++- .../expression/rewrite/TypeCoercionTest.java | 4 +- .../logical/AggregateDisassembleTest.java | 30 +- .../stats/ExpressionEstimationTest.java | 4 +- .../expressions/ExpressionEqualsTest.java | 9 +- .../doris/regression/RegressionTest.groovy | 8 +- .../nereids_syntax_p0/one_row_relation.groovy | 11 +- 335 files changed, 22638 insertions(+), 742 deletions(-) rename fe/fe-core/src/main/java/org/apache/doris/catalog/{BuiltinFunctions.java => BuiltinAggregateFunctions.java} (71%) create mode 100644 fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java delete mode 100644 fe/fe-core/src/main/java/org/apache/doris/catalog/FuncSig.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSignature.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignature.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DateTimeWithPrecision.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalSamePrecision.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalStddevPrecision.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalWiderPrecision.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExpressionTrait.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/FunctionTrait.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/IdenticalSignature.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/Nondeterministic.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/NullOrIdenticalSignature.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SearchSignature.java delete mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SignatureSupplier.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateParam.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Abs.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Acos.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesDecrypt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesEncrypt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AppendTrailingCharIfAbsent.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ascii.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Asin.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Atan.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Bin.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitLength.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAnd.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndCount.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNot.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNotCount.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapContains.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapCount.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapEmpty.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapFromString.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAll.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAny.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash64.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMax.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMin.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapNot.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOr.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOrCount.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetInRange.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetLimit.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapToString.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXorCount.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cbrt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceiling.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharLength.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharacterLength.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Concat.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConcatWs.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Conv.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConvertTz.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cos.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentDate.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTime.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTimestamp.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Curtime.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateFormat.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateTrunc.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateV2.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Day.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayName.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Degrees.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dexp.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog1.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog10.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dpow.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dsqrt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/E.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Elt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EndsWith.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EsQuery.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Exp.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ExtractUrlParameter.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FindInSet.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fmod.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fpow.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromBase64.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromUnixtime.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonDouble.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonInt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonString.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Greatest.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hex.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllCardinality.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllEmpty.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllHash.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HoursDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Initcap.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Instr.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonArray.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonObject.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonQuote.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExistsPath.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBigint.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBool.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractDouble.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractInt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractIsnull.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractString.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParse.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToInvalid.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToNull.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToValue.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnull.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToInvalid.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToValue.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullable.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToInvalid.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToNull.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToValue.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbType.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Least.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Left.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Length.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ln.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTime.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTimestamp.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Locate.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log10.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log2.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lower.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lpad.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ltrim.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MakeDate.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5Sum.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinutesDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MoneyFormat.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthName.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash332.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash364.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Negative.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NotNullOrEmpty.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Now.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullOrEmpty.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ParseUrl.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pi.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pmod.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Positive.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pow.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Power.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/QuantilePercent.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Radians.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Random.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpExtract.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpReplace.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Repeat.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Replace.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Reverse.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Right.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rpad.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rtrim.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondsDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sign.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sin.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sleep.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3sum.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Decrypt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Encrypt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Space.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SplitPart.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sqrt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAstext.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAswkt.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StCircle.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StContains.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StDistanceSphere.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeometryfromtext.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeomfromtext.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinefromtext.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinestringfromtext.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPoint.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolyfromtext.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygon.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygonfromtext.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StX.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StY.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StartsWith.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrLeft.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrRight.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SubBitmap.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Tan.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/TimeDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Timestamp.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBase64.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmap.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmapWithCheck.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDate.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDateV2.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDays.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToQuantileState.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Trim.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Unhex.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UnixTimestamp.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Upper.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UtcTimestamp.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Version.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekCeil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekFloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearWeek.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsDiff.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLikeLiteral.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLikeLiteral.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/types/JsonType.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/types/MapType.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/types/StructType.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/util/ResponsibilityChain.java diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index e531c34994..a1345ef57b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -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 STDDEV_FUNCTION_SET = + public static final ImmutableSet 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 DECIMAL_SAME_TYPE_SET = + public static final ImmutableSet 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 DECIMAL_WIDER_TYPE_SET = + public static final ImmutableSet DECIMAL_WIDER_TYPE_SET = new ImmutableSortedSet.Builder(String.CASE_INSENSITIVE_ORDER) .add("sum").add("avg").add("multi_distinct_sum").build(); - private static final ImmutableSet DECIMAL_FUNCTION_SET = + public static final ImmutableSet 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 TIME_FUNCTIONS_WITH_PRECISION = + public static final ImmutableSet 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> 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> 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 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 getArgTypesForNereids() { + if (argTypesForNereids.isPresent()) { + return argTypesForNereids.get(); + } else { + return Lists.newArrayList(collectChildReturnTypes()); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java similarity index 71% rename from fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinFunctions.java rename to fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java index ccdb895eaf..0dda9591d5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinFunctions.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java @@ -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 scalarFunctions = ImmutableList.of( - scalar(Substring.class, "substr", "substring"), - scalar(WeekOfYear.class), - scalar(Year.class) - ); - +public class BuiltinAggregateFunctions implements FunctionHelper { public final ImmutableList 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() {} } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java new file mode 100644 index 0000000000..98cb360efc --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java @@ -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 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() {} +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/FuncSig.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/FuncSig.java deleted file mode 100644 index 87a8d6a063..0000000000 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/FuncSig.java +++ /dev/null @@ -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 argumentsTypes; - - public FuncSig(DataType returnType, boolean hasVarArgs, List 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 argumentsTypes) { - return of(returnType, false, argumentsTypes); - } - - public static FuncSig of(DataType returnType, boolean hasVarArgs, List 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); - } - } -} diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java index fa91d2ff9e..e02edfec24 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java @@ -79,8 +79,8 @@ public class FunctionRegistry { } private void registerBuiltinFunctions(Map> 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 candidateBuilders) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSignature.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSignature.java new file mode 100644 index 0000000000..a1104a71e2 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSignature.java @@ -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 argumentsTypes; + public final int arity; + + public FunctionSignature(DataType returnType, boolean hasVarArgs, List 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 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 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 arguments, + BiFunction transform) { + List 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 argumentsTypes) { + return of(returnType, false, argumentsTypes); + } + + public static FunctionSignature of(DataType returnType, boolean hasVarArgs, List 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); + } + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/annotation/Developing.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/annotation/Developing.java index a839520cc3..65636d285d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/annotation/Developing.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/annotation/Developing.java @@ -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 ""; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java index 5f89695b31..2dec21bb76 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java @@ -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 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> 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 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 arguments = function.getArguments() + .stream().map(arg -> arg.accept(this, context)) + .collect(Collectors.toList()); + List 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 diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java index ce4f6e858f..3db5cf8358 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java @@ -142,6 +142,7 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor 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 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 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 newChildren = Lists.newArrayListWithCapacity(expr.arity()); - boolean changed = false; - for (int i = 0; i < implicitCastInputTypes.expectedInputTypes().size(); i++) { - AbstractDataType expectedType = implicitCastInputTypes.expectedInputTypes().get(i); - Optional 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 expectedInputTypes, ExpressionRewriteContext ctx) { + expr = expr.withChildren(child -> rewrite(child, ctx)); + List> 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 implicitCast(Expression input, AbstractDataType expected, - ExpressionRewriteContext ctx) { - Expression rewrittenInput = rewrite(input, ctx); - Optional 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> getInputImplicitCastTypes( + List inputs, List expectedTypes) { + Builder> implicitCastTypes = ImmutableList.builder(); + for (int i = 0; i < inputs.size(); i++) { + DataType argType = inputs.get(i).getDataType(); + AbstractDataType expectedType = expectedTypes.get(i); + Optional 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> castTypes) { + return expr.withChildren((child, childIndex) -> { + DataType argType = child.getDataType(); + Optional castType = castTypes.get(childIndex); + if (castType.isPresent() && !castType.get().equals(argType)) { + return new Cast(child, castType.get()); + } else { + return child; + } + }); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java index 3deb794412..c4e3db8765 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java @@ -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 globalOutputSMap = Maps.newHashMap(); - Pair>, Boolean> ret - = firstDisassemble(aggregate, globalOutputSMap); - if (!ret.second) { - return ret.first; + Map globalOutputSMap = Maps.newHashMap(); + Pair>, Boolean> result + = disassembleAggregateFunction(aggregate, globalOutputSMap); + LogicalAggregate> 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>> secondDisassemble( + private LogicalAggregate>> disassembleDistinct( LogicalAggregate> aggregate, Map globalOutputSMap) { - LogicalAggregate local = aggregate.child(); + LogicalAggregate localDistinct = aggregate.child(); // replace expression in globalOutputExprs and globalGroupByExprs - List globalOutputExprs = local.getOutputExpressions().stream() + List globalOutputExprs = localDistinct.getOutputExpressions().stream() .map(e -> ExpressionUtils.replace(e, globalOutputSMap)) .map(NamedExpression.class::cast) .collect(Collectors.toList()); // generate new plan - LogicalAggregate> globalAggregate = new LogicalAggregate<>( - local.getGroupByExpressions(), + LogicalAggregate> 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>, Boolean> firstDisassemble( + private Pair>, Boolean> disassembleAggregateFunction( LogicalAggregate aggregate, Map 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 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); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/TreeNode.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/TreeNode.java index 04381846ab..f8dc7cd4bf 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/TreeNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/TreeNode.java @@ -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 withChildren(List children); + default NODE_TYPE withChildren(Function 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 rewriter) { + Builder 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 rewriteFunction) { + Builder 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> { } } + default void foreachUp(Consumer> 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 diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java index 7210f25ec1..b1d037c282 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java @@ -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 implements ComputeNullable { +public abstract class Expression extends AbstractTreeNode 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 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; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java index 326750d1cb..eb7ec5d267 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java @@ -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 diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/BoundFunction.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/BoundFunction.java index a56f787a21..fedb42825c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/BoundFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/BoundFunction.java @@ -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 children) { + super(children); + this.name = Objects.requireNonNull(name, "name can not be null"); } - public List getArguments() { - return children; + public String getName() { + return name; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeNullable.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeNullable.java index 1feb0c511a..ba1bb71845 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeNullable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeNullable.java @@ -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 { } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignature.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignature.java new file mode 100644 index 0000000000..7416b56910 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignature.java @@ -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 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 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; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DateTimeWithPrecision.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DateTimeWithPrecision.java new file mode 100644 index 0000000000..bc42728c0f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DateTimeWithPrecision.java @@ -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 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); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalSamePrecision.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalSamePrecision.java new file mode 100644 index 0000000000..41d17e3474 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalSamePrecision.java @@ -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 { +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalStddevPrecision.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalStddevPrecision.java new file mode 100644 index 0000000000..612aa7ec56 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalStddevPrecision.java @@ -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; +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalWiderPrecision.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalWiderPrecision.java new file mode 100644 index 0000000000..b92357f118 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/DecimalWiderPrecision.java @@ -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 { +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java new file mode 100644 index 0000000000..1edf15f1f4 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java @@ -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()); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExpressionTrait.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExpressionTrait.java new file mode 100644 index 0000000000..b936544650 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExpressionTrait.java @@ -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 { + + boolean nullable(); + + default boolean notNullable() { + return !nullable(); + } + + default List getArguments() { + return children(); + } + + default DataType getDataType() throws UnboundException { + throw new UnboundException("dataType"); + } + + default String toSql() throws UnboundException { + throw new UnboundException("sql"); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/FunctionTrait.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/FunctionTrait.java new file mode 100644 index 0000000000..76613afb0e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/FunctionTrait.java @@ -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(); +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/IdenticalSignature.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/IdenticalSignature.java new file mode 100644 index 0000000000..c2a3dc7390 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/IdenticalSignature.java @@ -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()); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java new file mode 100644 index 0000000000..d9891d4d2f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java @@ -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()); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/Nondeterministic.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/Nondeterministic.java new file mode 100644 index 0000000000..8ad8149aea --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/Nondeterministic.java @@ -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 { +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/NullOrIdenticalSignature.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/NullOrIdenticalSignature.java new file mode 100644 index 0000000000..cc2d2fdf92 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/NullOrIdenticalSignature.java @@ -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()); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/PropagateNullable.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/PropagateNullable.java index b5aac27cb8..9fb17ccc47 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/PropagateNullable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/PropagateNullable.java @@ -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. */ diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SearchSignature.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SearchSignature.java new file mode 100644 index 0000000000..11ed4a4834 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SearchSignature.java @@ -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 signatures; + private final List arguments; + + // param1: signature type + // param2: real argument type + // return: is the real argument type matches the signature type? + private List> typePredicatePerRound = Lists.newArrayList(); + + public SearchSignature(List signatures, List arguments) { + this.signatures = signatures; + this.arguments = arguments; + } + + public static SearchSignature from(List signatures, List arguments) { + return new SearchSignature(signatures, arguments); + } + + public SearchSignature orElseSearch(BiFunction typePredicate) { + typePredicatePerRound.add(typePredicate); + return this; + } + + /** + * result. + * @return Optional functionSignature result + */ + public Optional result() { + // search every round + for (BiFunction 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 result = result(); + if (!result.isPresent()) { + throwCanNotFoundFunctionException(functionName, arguments); + } + return result.get(); + } + + private boolean doMatchArity(FunctionSignature sig, List 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 arguments, + BiFunction 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 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); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SignatureSupplier.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SignatureSupplier.java deleted file mode 100644 index 58967f9431..0000000000 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SignatureSupplier.java +++ /dev/null @@ -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 getSignatures(); - - List getArguments(); - - @Override - default List expectedInputTypes() { - int arity = arity(); - List candidateFunctions = getSignatures() - .stream() - .filter(s -> (s.hasVarArgs && arity >= s.argumentsTypes.size()) - || (!s.hasVarArgs && s.argumentsTypes.size() == arity)) - .collect(Collectors.toList()); - List 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 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 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 expectTypes, - List 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 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); - } -} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateFunction.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateFunction.java index f8fcf56b4d..f01e1839cd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateFunction.java @@ -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 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> 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(); + } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateParam.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateParam.java new file mode 100644 index 0000000000..bf31599c1a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AggregateParam.java @@ -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> 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> 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> 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); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Avg.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Avg.java index 4675387146..cea26f3344 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Avg.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Avg.java @@ -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 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 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 expectedInputTypes() { - return EXPECTED_INPUT_TYPES; + if (isGlobal() && inputTypesBeforeDissemble().isPresent()) { + return ImmutableList.of(); + } else { + return EXPECTED_INPUT_TYPES; + } } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java index 0dea798b04..637bc60e01 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java @@ -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 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 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 diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Max.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Max.java index 899e7833c3..36e6e79a41 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Max.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Max.java @@ -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 children) { + public Max withChildren(List 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 diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Min.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Min.java index 5bc4acfefb..c350640d6d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Min.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Min.java @@ -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 children) { + public Min withChildren(List 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 diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Sum.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Sum.java index 8e12fd36e0..997bf0757e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Sum.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Sum.java @@ -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 children) { + public Sum withChildren(List 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 diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Abs.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Abs.java new file mode 100644 index 0000000000..3883de6f11 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Abs.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Abs(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAbs(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Acos.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Acos.java new file mode 100644 index 0000000000..183ee150f1 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Acos.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Acos(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAcos(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesDecrypt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesDecrypt.java new file mode 100644 index 0000000000..ccfdd741d8 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesDecrypt.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAesDecrypt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesEncrypt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesEncrypt.java new file mode 100644 index 0000000000..1572bbc428 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesEncrypt.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAesEncrypt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AppendTrailingCharIfAbsent.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AppendTrailingCharIfAbsent.java new file mode 100644 index 0000000000..8059247197 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AppendTrailingCharIfAbsent.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new AppendTrailingCharIfAbsent(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAppendTrailingCharIfAbsent(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ascii.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ascii.java new file mode 100644 index 0000000000..1893028204 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ascii.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Ascii(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAscii(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Asin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Asin.java new file mode 100644 index 0000000000..1b852772d7 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Asin.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Asin(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAsin(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Atan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Atan.java new file mode 100644 index 0000000000..a43455d54d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Atan.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Atan(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitAtan(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Bin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Bin.java new file mode 100644 index 0000000000..4be26c7d38 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Bin.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Bin(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBin(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitLength.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitLength.java new file mode 100644 index 0000000000..399d9a04d3 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitLength.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitLength(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitLength(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAnd.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAnd.java new file mode 100644 index 0000000000..f14a230b68 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAnd.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapAnd(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndCount.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndCount.java new file mode 100644 index 0000000000..5b791b6cdb --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndCount.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapAndCount(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNot.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNot.java new file mode 100644 index 0000000000..29d97c5743 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNot.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new BitmapAndNot(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapAndNot(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNotCount.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNotCount.java new file mode 100644 index 0000000000..5ced76a465 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapAndNotCount.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new BitmapAndNotCount(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapAndNotCount(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapContains.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapContains.java new file mode 100644 index 0000000000..db5343b6d9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapContains.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new BitmapContains(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapContains(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapCount.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapCount.java new file mode 100644 index 0000000000..b33db825b8 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapCount.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitmapCount(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapCount(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapEmpty.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapEmpty.java new file mode 100644 index 0000000000..6c0477d855 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapEmpty.java @@ -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 SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BitmapType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public BitmapEmpty() { + super("bitmap_empty"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapEmpty(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapFromString.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapFromString.java new file mode 100644 index 0000000000..69d8db12fe --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapFromString.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitmapFromString(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapFromString(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAll.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAll.java new file mode 100644 index 0000000000..8047c7d73e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAll.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new BitmapHasAll(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapHasAll(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAny.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAny.java new file mode 100644 index 0000000000..99dae29742 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHasAny.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new BitmapHasAny(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapHasAny(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash.java new file mode 100644 index 0000000000..75349f9939 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitmapHash(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapHash(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash64.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash64.java new file mode 100644 index 0000000000..e38e6b075d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapHash64.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitmapHash64(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapHash64(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMax.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMax.java new file mode 100644 index 0000000000..f788147f89 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMax.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitmapMax(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapMax(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMin.java new file mode 100644 index 0000000000..5e656875e6 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapMin.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitmapMin(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapMin(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapNot.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapNot.java new file mode 100644 index 0000000000..703e42e03f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapNot.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new BitmapNot(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapNot(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOr.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOr.java new file mode 100644 index 0000000000..aa6e94e788 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOr.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapOr(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOrCount.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOrCount.java new file mode 100644 index 0000000000..85afd374bb --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapOrCount.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapOrCount(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetInRange.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetInRange.java new file mode 100644 index 0000000000..0b2830efe9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetInRange.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 3); + return new BitmapSubsetInRange(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapSubsetInRange(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetLimit.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetLimit.java new file mode 100644 index 0000000000..623fc2641e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapSubsetLimit.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 3); + return new BitmapSubsetLimit(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapSubsetLimit(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapToString.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapToString.java new file mode 100644 index 0000000000..9d689deb32 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapToString.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new BitmapToString(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapToString(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXor.java new file mode 100644 index 0000000000..f3112acd0b --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXor.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapXor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXorCount.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXorCount.java new file mode 100644 index 0000000000..88cb506d2b --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitmapXorCount.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitBitmapXorCount(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cbrt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cbrt.java new file mode 100644 index 0000000000..1f246eec37 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cbrt.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Cbrt(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCbrt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java new file mode 100644 index 0000000000..6bcb2264d3 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Ceil(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceiling.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceiling.java new file mode 100644 index 0000000000..b1e93103c9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceiling.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Ceiling(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCeiling(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharLength.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharLength.java new file mode 100644 index 0000000000..8d8b3c3410 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharLength.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new CharLength(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCharLength(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharacterLength.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharacterLength.java new file mode 100644 index 0000000000..dc93283922 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CharacterLength.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new CharacterLength(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCharacterLength(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java new file mode 100644 index 0000000000..9777f8e1a8 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() >= 1); + return new Coalesce(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCoalesce(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Concat.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Concat.java new file mode 100644 index 0000000000..9f89f5fd5a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Concat.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() >= 1); + return new Concat(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitConcat(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConcatWs.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConcatWs.java new file mode 100644 index 0000000000..7661026206 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConcatWs.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitConcatWs(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Conv.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Conv.java new file mode 100644 index 0000000000..4f1596db82 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Conv.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 3); + return new Conv(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitConv(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConvertTz.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConvertTz.java new file mode 100644 index 0000000000..5e1462478a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ConvertTz.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 3); + return new ConvertTz(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitConvertTz(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cos.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cos.java new file mode 100644 index 0000000000..49abf8b099 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Cos.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Cos(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCos(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentDate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentDate.java new file mode 100644 index 0000000000..bc071587e0 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentDate.java @@ -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 SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public CurrentDate() { + super("current_date"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCurrentDate(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTime.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTime.java new file mode 100644 index 0000000000..038601194e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTime.java @@ -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 SIGNATURES = ImmutableList.of( + FunctionSignature.ret(TimeType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public CurrentTime() { + super("current_time"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCurrentTime(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTimestamp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTimestamp.java new file mode 100644 index 0000000000..44e8fab924 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CurrentTimestamp.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCurrentTimestamp(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Curtime.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Curtime.java new file mode 100644 index 0000000000..ee9b1a171d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Curtime.java @@ -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 SIGNATURES = ImmutableList.of( + FunctionSignature.ret(TimeType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public Curtime() { + super("curtime"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitCurtime(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java new file mode 100644 index 0000000000..737966bb2d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Date(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDate(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java new file mode 100644 index 0000000000..0bbf3b0244 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new DateDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDateDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateFormat.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateFormat.java new file mode 100644 index 0000000000..4b309e6934 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateFormat.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new DateFormat(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDateFormat(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateTrunc.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateTrunc.java new file mode 100644 index 0000000000..c0435f8ee2 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateTrunc.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new DateTrunc(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDateTrunc(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateV2.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateV2.java new file mode 100644 index 0000000000..b03dbc2de7 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateV2.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new DateV2(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDateV2(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Day.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Day.java new file mode 100644 index 0000000000..66c0d63c91 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Day.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Day(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDay(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java new file mode 100644 index 0000000000..fa0cd18401 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDayCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java new file mode 100644 index 0000000000..a2044f9520 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java @@ -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 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 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 getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDayFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayName.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayName.java new file mode 100644 index 0000000000..34fe76ef2c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayName.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new DayName(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDayName(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java new file mode 100644 index 0000000000..877a1a6e35 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new DayOfMonth(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDayOfMonth(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java new file mode 100644 index 0000000000..6b58420962 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new DayOfWeek(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDayOfWeek(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java new file mode 100644 index 0000000000..06560aaea7 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new DayOfYear(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDayOfYear(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java new file mode 100644 index 0000000000..41cdf8f59a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 2); + return new DaysDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDaysDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java new file mode 100644 index 0000000000..9473c43d27 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java @@ -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 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 children) { + Preconditions.checkArgument(children.size() == 1); + return new Dceil(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDceil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Degrees.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Degrees.java new file mode 100644 index 0000000000..508b8a2890 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Degrees.java @@ -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 'degrees'. This class is generated by GenerateScalarFunction. + */ +public class Degrees extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Degrees(Expression arg) { + super("degrees", arg); + } + + /** + * withChildren. + */ + @Override + public Degrees withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Degrees(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDegrees(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dexp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dexp.java new file mode 100644 index 0000000000..fc15c99a26 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dexp.java @@ -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 'dexp'. This class is generated by GenerateScalarFunction. + */ +public class Dexp extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Dexp(Expression arg) { + super("dexp", arg); + } + + /** + * withChildren. + */ + @Override + public Dexp withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Dexp(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDexp(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java new file mode 100644 index 0000000000..d02b79c515 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java @@ -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 'dfloor'. This class is generated by GenerateScalarFunction. + */ +public class Dfloor extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Dfloor(Expression arg) { + super("dfloor", arg); + } + + /** + * withChildren. + */ + @Override + public Dfloor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Dfloor(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDfloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog1.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog1.java new file mode 100644 index 0000000000..dca25d2636 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog1.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.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 'dlog1'. This class is generated by GenerateScalarFunction. + */ +public class Dlog1 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Dlog1(Expression arg) { + super("dlog1", arg); + } + + /** + * withChildren. + */ + @Override + public Dlog1 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Dlog1(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDlog1(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog10.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog10.java new file mode 100644 index 0000000000..b5479b2681 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog10.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.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 'dlog10'. This class is generated by GenerateScalarFunction. + */ +public class Dlog10 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Dlog10(Expression arg) { + super("dlog10", arg); + } + + /** + * withChildren. + */ + @Override + public Dlog10 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Dlog10(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDlog10(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dpow.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dpow.java new file mode 100644 index 0000000000..840c3a30ba --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dpow.java @@ -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.DoubleType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'dpow'. This class is generated by GenerateScalarFunction. + */ +public class Dpow extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Dpow(Expression arg0, Expression arg1) { + super("dpow", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Dpow withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Dpow(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDpow(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java new file mode 100644 index 0000000000..1948652a82 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java @@ -0,0 +1,82 @@ +// 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.DoubleType; +import org.apache.doris.nereids.types.IntegerType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'dround'. This class is generated by GenerateScalarFunction. + */ +public class Dround extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Dround(Expression arg) { + super("dround", arg); + } + + /** + * constructor with 2 arguments. + */ + public Dround(Expression arg0, Expression arg1) { + super("dround", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Dround withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2); + if (children.size() == 1) { + return new Dround(children.get(0)); + } else { + return new Dround(children.get(0), children.get(1)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDround(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dsqrt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dsqrt.java new file mode 100644 index 0000000000..cd8d56c38c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dsqrt.java @@ -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 'dsqrt'. This class is generated by GenerateScalarFunction. + */ +public class Dsqrt extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Dsqrt(Expression arg) { + super("dsqrt", arg); + } + + /** + * withChildren. + */ + @Override + public Dsqrt withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Dsqrt(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitDsqrt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/E.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/E.java new file mode 100644 index 0000000000..6530f5b16a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/E.java @@ -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.DoubleType; + +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'e'. This class is generated by GenerateScalarFunction. + */ +public class E extends ScalarFunction + implements LeafExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public E() { + super("e"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitE(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Elt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Elt.java new file mode 100644 index 0000000000..3ee61bb757 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Elt.java @@ -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.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.IntegerType; +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 'elt'. This class is generated by GenerateScalarFunction. + */ +public class Elt extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(IntegerType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).varArgs(IntegerType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 or more arguments. + */ + public Elt(Expression arg0, Expression arg1, Expression... varArgs) { + super("elt", ExpressionUtils.mergeArguments(arg0, arg1, varArgs)); + } + + /** + * withChildren. + */ + @Override + public Elt withChildren(List children) { + Preconditions.checkArgument(children.size() >= 2); + return new Elt(children.get(0), children.get(1), + children.subList(2, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitElt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EndsWith.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EndsWith.java new file mode 100644 index 0000000000..60b923262d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EndsWith.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.BooleanType; +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 'ends_with'. This class is generated by GenerateScalarFunction. + */ +public class EndsWith extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BooleanType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public EndsWith(Expression arg0, Expression arg1) { + super("ends_with", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public EndsWith withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new EndsWith(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitEndsWith(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EsQuery.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EsQuery.java new file mode 100644 index 0000000000..6ceca23bbc --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/EsQuery.java @@ -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.BooleanType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'esquery'. This class is generated by GenerateScalarFunction. + */ +public class EsQuery extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 2 arguments. + */ + public EsQuery(Expression arg0, Expression arg1) { + super("esquery", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public EsQuery withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new EsQuery(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitEsQuery(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Exp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Exp.java new file mode 100644 index 0000000000..e71064781b --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Exp.java @@ -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 'exp'. This class is generated by GenerateScalarFunction. + */ +public class Exp extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Exp(Expression arg) { + super("exp", arg); + } + + /** + * withChildren. + */ + @Override + public Exp withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Exp(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitExp(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ExtractUrlParameter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ExtractUrlParameter.java new file mode 100644 index 0000000000..5e48d17aac --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ExtractUrlParameter.java @@ -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.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'extract_url_parameter'. This class is generated by GenerateScalarFunction. + */ +public class ExtractUrlParameter extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 2 arguments. + */ + public ExtractUrlParameter(Expression arg0, Expression arg1) { + super("extract_url_parameter", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public ExtractUrlParameter withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new ExtractUrlParameter(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitExtractUrlParameter(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FindInSet.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FindInSet.java new file mode 100644 index 0000000000..8b17d28cb5 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FindInSet.java @@ -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.BinaryExpression; +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 'find_in_set'. This class is generated by GenerateScalarFunction. + */ +public class FindInSet extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public FindInSet(Expression arg0, Expression arg1) { + super("find_in_set", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public FindInSet withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new FindInSet(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitFindInSet(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java new file mode 100644 index 0000000000..53cacf774a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java @@ -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 'floor'. This class is generated by GenerateScalarFunction. + */ +public class Floor extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Floor(Expression arg) { + super("floor", arg); + } + + /** + * withChildren. + */ + @Override + public Floor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Floor(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fmod.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fmod.java new file mode 100644 index 0000000000..1193caf675 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fmod.java @@ -0,0 +1,70 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DoubleType; +import org.apache.doris.nereids.types.FloatType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'fmod'. This class is generated by GenerateScalarFunction. + */ +public class Fmod extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(FloatType.INSTANCE).args(FloatType.INSTANCE, FloatType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Fmod(Expression arg0, Expression arg1) { + super("fmod", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Fmod withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Fmod(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitFmod(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fpow.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fpow.java new file mode 100644 index 0000000000..9d00b53a86 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Fpow.java @@ -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.DoubleType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'fpow'. This class is generated by GenerateScalarFunction. + */ +public class Fpow extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Fpow(Expression arg0, Expression arg1) { + super("fpow", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Fpow withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Fpow(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitFpow(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromBase64.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromBase64.java new file mode 100644 index 0000000000..31a97fc8a7 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromBase64.java @@ -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.UnaryExpression; +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 'from_base64'. This class is generated by GenerateScalarFunction. + */ +public class FromBase64 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public FromBase64(Expression arg) { + super("from_base64", arg); + } + + /** + * withChildren. + */ + @Override + public FromBase64 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new FromBase64(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitFromBase64(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java new file mode 100644 index 0000000000..ff61648753 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromDays.java @@ -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.DateType; +import org.apache.doris.nereids.types.IntegerType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'from_days'. This class is generated by GenerateScalarFunction. + */ +public class FromDays extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateType.INSTANCE).args(IntegerType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public FromDays(Expression arg) { + super("from_days", arg); + } + + /** + * withChildren. + */ + @Override + public FromDays withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new FromDays(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitFromDays(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromUnixtime.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromUnixtime.java new file mode 100644 index 0000000000..2b2cd76adb --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromUnixtime.java @@ -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.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.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 'from_unixtime'. This class is generated by GenerateScalarFunction. + */ +public class FromUnixtime extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IntegerType.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IntegerType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IntegerType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public FromUnixtime(Expression arg) { + super("from_unixtime", arg); + } + + /** + * constructor with 2 arguments. + */ + public FromUnixtime(Expression arg0, Expression arg1) { + super("from_unixtime", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public FromUnixtime withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2); + if (children.size() == 1) { + return new FromUnixtime(children.get(0)); + } else { + return new FromUnixtime(children.get(0), children.get(1)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitFromUnixtime(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonDouble.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonDouble.java new file mode 100644 index 0000000000..3ec8420bdf --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonDouble.java @@ -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.DoubleType; +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 'get_json_double'. This class is generated by GenerateScalarFunction. + */ +public class GetJsonDouble extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(DoubleType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public GetJsonDouble(Expression arg0, Expression arg1) { + super("get_json_double", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public GetJsonDouble withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new GetJsonDouble(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitGetJsonDouble(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonInt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonInt.java new file mode 100644 index 0000000000..1e1bc3430a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonInt.java @@ -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.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 'get_json_int'. This class is generated by GenerateScalarFunction. + */ +public class GetJsonInt extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public GetJsonInt(Expression arg0, Expression arg1) { + super("get_json_int", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public GetJsonInt withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new GetJsonInt(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitGetJsonInt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonString.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonString.java new file mode 100644 index 0000000000..54c5bb732e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/GetJsonString.java @@ -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 'get_json_string'. This class is generated by GenerateScalarFunction. + */ +public class GetJsonString extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 GetJsonString(Expression arg0, Expression arg1) { + super("get_json_string", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public GetJsonString withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new GetJsonString(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitGetJsonString(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Greatest.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Greatest.java new file mode 100644 index 0000000000..20da28c6b9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Greatest.java @@ -0,0 +1,91 @@ +// 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.DateTimeType; +import org.apache.doris.nereids.types.DateTimeV2Type; +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 'greatest'. This class is generated by GenerateScalarFunction. + */ +public class Greatest extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + 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(DecimalV2Type.MAX).varArgs(DecimalV2Type.MAX), + FunctionSignature.ret(DateTimeType.INSTANCE).varArgs(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).varArgs(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).varArgs(StringType.INSTANCE) + ); + + /** + * constructor with 1 or more arguments. + */ + public Greatest(Expression arg, Expression... varArgs) { + super("greatest", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public Greatest withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new Greatest(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitGreatest(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hex.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hex.java new file mode 100644 index 0000000000..7138be1668 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hex.java @@ -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.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.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 'hex'. This class is generated by GenerateScalarFunction. + */ +public class Hex extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(BigIntType.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Hex(Expression arg) { + super("hex", arg); + } + + /** + * withChildren. + */ + @Override + public Hex withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Hex(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHex(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllCardinality.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllCardinality.java new file mode 100644 index 0000000000..8be387aba1 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllCardinality.java @@ -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.HllType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'hll_cardinality'. This class is generated by GenerateScalarFunction. + */ +public class HllCardinality extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(HllType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public HllCardinality(Expression arg) { + super("hll_cardinality", arg); + } + + /** + * withChildren. + */ + @Override + public HllCardinality withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new HllCardinality(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHllCardinality(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllEmpty.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllEmpty.java new file mode 100644 index 0000000000..d596317e7e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllEmpty.java @@ -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.HllType; + +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'hll_empty'. This class is generated by GenerateScalarFunction. + */ +public class HllEmpty extends ScalarFunction + implements LeafExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(HllType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public HllEmpty() { + super("hll_empty"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHllEmpty(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllHash.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllHash.java new file mode 100644 index 0000000000..dbe4ec832a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HllHash.java @@ -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.HllType; +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 'hll_hash'. This class is generated by GenerateScalarFunction. + */ +public class HllHash extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(HllType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(HllType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public HllHash(Expression arg) { + super("hll_hash", arg); + } + + /** + * withChildren. + */ + @Override + public HllHash withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new HllHash(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHllHash(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java new file mode 100644 index 0000000000..fcdcc3b33c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java @@ -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 'hour'. This class is generated by GenerateScalarFunction. + */ +public class Hour extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Hour(Expression arg) { + super("hour", arg); + } + + /** + * withChildren. + */ + @Override + public Hour withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Hour(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHour(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java new file mode 100644 index 0000000000..1ec2c82dbd --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java @@ -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 'hour_ceil'. This class is generated by GenerateScalarFunction. + */ +public class HourCeil extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE) + .args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public HourCeil(Expression arg) { + super("hour_ceil", arg); + } + + /** + * constructor with 2 arguments. + */ + public HourCeil(Expression arg0, Expression arg1) { + super("hour_ceil", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public HourCeil(Expression arg0, Expression arg1, Expression arg2) { + super("hour_ceil", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public HourCeil withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new HourCeil(children.get(0)); + } else if (children.size() == 2) { + return new HourCeil(children.get(0), children.get(1)); + } else { + return new HourCeil(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHourCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java new file mode 100644 index 0000000000..1cf208205f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java @@ -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 'hour_floor'. This class is generated by GenerateScalarFunction. + */ +public class HourFloor extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE) + .args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public HourFloor(Expression arg) { + super("hour_floor", arg); + } + + /** + * constructor with 2 arguments. + */ + public HourFloor(Expression arg0, Expression arg1) { + super("hour_floor", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public HourFloor(Expression arg0, Expression arg1, Expression arg2) { + super("hour_floor", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public HourFloor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new HourFloor(children.get(0)); + } else if (children.size() == 2) { + return new HourFloor(children.get(0), children.get(1)); + } else { + return new HourFloor(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHourFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HoursDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HoursDiff.java new file mode 100644 index 0000000000..245d5ee528 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HoursDiff.java @@ -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 'hours_diff'. This class is generated by GenerateScalarFunction. + */ +public class HoursDiff extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 HoursDiff(Expression arg0, Expression arg1) { + super("hours_diff", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public HoursDiff withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new HoursDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitHoursDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java new file mode 100644 index 0000000000..be370bf22f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java @@ -0,0 +1,146 @@ +// 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.catalog.ScalarType; +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.trees.expressions.Expression; +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 org.apache.doris.nereids.types.BooleanType; +import org.apache.doris.nereids.types.DataType; +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 com.google.common.base.Preconditions; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableList; + +import java.util.List; +import java.util.function.Supplier; + +/** + * ScalarFunction 'if'. This class is generated by GenerateScalarFunction. + */ +public class If extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE) + .args(BooleanType.INSTANCE, BooleanType.INSTANCE, BooleanType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE) + .args(BooleanType.INSTANCE, TinyIntType.INSTANCE, TinyIntType.INSTANCE), + FunctionSignature.ret(SmallIntType.INSTANCE) + .args(BooleanType.INSTANCE, SmallIntType.INSTANCE, SmallIntType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE) + .args(BooleanType.INSTANCE, IntegerType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(BigIntType.INSTANCE) + .args(BooleanType.INSTANCE, BigIntType.INSTANCE, BigIntType.INSTANCE), + FunctionSignature.ret(LargeIntType.INSTANCE) + .args(BooleanType.INSTANCE, LargeIntType.INSTANCE, LargeIntType.INSTANCE), + FunctionSignature.ret(FloatType.INSTANCE) + .args(BooleanType.INSTANCE, FloatType.INSTANCE, FloatType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE) + .args(BooleanType.INSTANCE, DoubleType.INSTANCE, DoubleType.INSTANCE), + FunctionSignature.ret(DateTimeType.INSTANCE) + .args(BooleanType.INSTANCE, DateTimeType.INSTANCE, DateTimeType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(BooleanType.INSTANCE, DateType.INSTANCE, DateType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE) + .args(BooleanType.INSTANCE, DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateV2Type.INSTANCE) + .args(BooleanType.INSTANCE, DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DecimalV2Type.MAX).args(BooleanType.INSTANCE, DecimalV2Type.MAX, DecimalV2Type.MAX), + FunctionSignature.ret(BitmapType.INSTANCE) + .args(BooleanType.INSTANCE, BitmapType.INSTANCE, BitmapType.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(BooleanType.INSTANCE, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE) + .args(BooleanType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE) + ); + + private final Supplier widerType = Suppliers.memoize(() -> { + List argumentsTypes = getSignature().argumentsTypes; + Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType( + argumentsTypes.get(1).toCatalogDataType(), + argumentsTypes.get(2).toCatalogDataType(), + true); + return DataType.fromCatalogType(assignmentCompatibleType); + }); + + /** + * constructor with 3 arguments. + */ + public If(Expression arg0, Expression arg1, Expression arg2) { + super("if", arg0, arg1, arg2); + } + + @Override + protected FunctionSignature computeSignature(FunctionSignature signature) { + DataType widerType = this.widerType.get(); + signature = signature.withArgumentTypes(children(), (sigType, argType) -> widerType) + .withReturnType(widerType); + return super.computeSignature(signature); + } + + /** + * custom compute nullable. + */ + @Override + public boolean nullable() { + for (int i = 1; i < arity(); i++) { + if (child(i).nullable()) { + return true; + } + } + return false; + } + + /** + * withChildren. + */ + @Override + public If withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new If(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitIf(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Initcap.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Initcap.java new file mode 100644 index 0000000000..a0dcc3b312 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Initcap.java @@ -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.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'initcap'. This class is generated by GenerateScalarFunction. + */ +public class Initcap extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public Initcap(Expression arg) { + super("initcap", arg); + } + + /** + * withChildren. + */ + @Override + public Initcap withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Initcap(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitInitcap(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Instr.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Instr.java new file mode 100644 index 0000000000..747f5f7d51 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Instr.java @@ -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.BinaryExpression; +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 'instr'. This class is generated by GenerateScalarFunction. + */ +public class Instr extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Instr(Expression arg0, Expression arg1) { + super("instr", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Instr withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Instr(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitInstr(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonArray.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonArray.java new file mode 100644 index 0000000000..d3758db52a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonArray.java @@ -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.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 'json_array'. This class is generated by GenerateScalarFunction. + */ +public class JsonArray extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 or more arguments. + */ + public JsonArray(Expression arg, Expression... varArgs) { + super("json_array", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public JsonArray withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new JsonArray(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonArray(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonObject.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonObject.java new file mode 100644 index 0000000000..ae1f3c7bf1 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonObject.java @@ -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.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 'json_object'. This class is generated by GenerateScalarFunction. + */ +public class JsonObject extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 or more arguments. + */ + public JsonObject(Expression arg, Expression... varArgs) { + super("json_object", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public JsonObject withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new JsonObject(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonObject(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonQuote.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonQuote.java new file mode 100644 index 0000000000..264d07e4aa --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonQuote.java @@ -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.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'json_quote'. This class is generated by GenerateScalarFunction. + */ +public class JsonQuote extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonQuote(Expression arg) { + super("json_quote", arg); + } + + /** + * withChildren. + */ + @Override + public JsonQuote withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonQuote(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonQuote(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExistsPath.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExistsPath.java new file mode 100644 index 0000000000..e835e14133 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExistsPath.java @@ -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.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.BooleanType; +import org.apache.doris.nereids.types.JsonType; +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 'jsonb_exists_path'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExistsPath extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BooleanType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExistsPath(Expression arg0, Expression arg1) { + super("jsonb_exists_path", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExistsPath withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExistsPath(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExistsPath(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java new file mode 100644 index 0000000000..2361d26b18 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java @@ -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.JsonType; +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 'jsonb_extract'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExtract extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(JsonType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExtract(Expression arg0, Expression arg1) { + super("jsonb_extract", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExtract withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExtract(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExtract(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBigint.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBigint.java new file mode 100644 index 0000000000..2017781d10 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBigint.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.BigIntType; +import org.apache.doris.nereids.types.JsonType; +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 'jsonb_extract_bigint'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExtractBigint extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BigIntType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExtractBigint(Expression arg0, Expression arg1) { + super("jsonb_extract_bigint", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExtractBigint withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExtractBigint(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExtractBigint(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBool.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBool.java new file mode 100644 index 0000000000..cd75149329 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractBool.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.BooleanType; +import org.apache.doris.nereids.types.JsonType; +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 'jsonb_extract_bool'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExtractBool extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BooleanType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExtractBool(Expression arg0, Expression arg1) { + super("jsonb_extract_bool", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExtractBool withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExtractBool(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExtractBool(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractDouble.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractDouble.java new file mode 100644 index 0000000000..f7f0bced32 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractDouble.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DoubleType; +import org.apache.doris.nereids.types.JsonType; +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 'jsonb_extract_double'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExtractDouble extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(DoubleType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExtractDouble(Expression arg0, Expression arg1) { + super("jsonb_extract_double", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExtractDouble withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExtractDouble(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExtractDouble(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractInt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractInt.java new file mode 100644 index 0000000000..22ed4c7b1b --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractInt.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.JsonType; +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 'jsonb_extract_int'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExtractInt extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExtractInt(Expression arg0, Expression arg1) { + super("jsonb_extract_int", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExtractInt withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExtractInt(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExtractInt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractIsnull.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractIsnull.java new file mode 100644 index 0000000000..dadfa58ad4 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractIsnull.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.BooleanType; +import org.apache.doris.nereids.types.JsonType; +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 'jsonb_extract_isnull'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExtractIsnull extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BooleanType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExtractIsnull(Expression arg0, Expression arg1) { + super("jsonb_extract_isnull", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExtractIsnull withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExtractIsnull(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExtractIsnull(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractString.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractString.java new file mode 100644 index 0000000000..57d0e7d6c2 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtractString.java @@ -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.JsonType; +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 'jsonb_extract_string'. This class is generated by GenerateScalarFunction. + */ +public class JsonbExtractString extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(StringType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbExtractString(Expression arg0, Expression arg1) { + super("jsonb_extract_string", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbExtractString withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbExtractString(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbExtractString(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParse.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParse.java new file mode 100644 index 0000000000..46b45e7e80 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParse.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParse extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParse(Expression arg) { + super("jsonb_parse", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParse withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParse(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParse(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToInvalid.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToInvalid.java new file mode 100644 index 0000000000..56cba75f79 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToInvalid.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_error_to_invalid'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseErrorToInvalid extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParseErrorToInvalid(Expression arg) { + super("jsonb_parse_error_to_invalid", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParseErrorToInvalid withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParseErrorToInvalid(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseErrorToInvalid(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToNull.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToNull.java new file mode 100644 index 0000000000..0fcadaa171 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToNull.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_error_to_null'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseErrorToNull extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParseErrorToNull(Expression arg) { + super("jsonb_parse_error_to_null", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParseErrorToNull withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParseErrorToNull(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseErrorToNull(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToValue.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToValue.java new file mode 100644 index 0000000000..dc3c11ea33 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseErrorToValue.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_error_to_value'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseErrorToValue extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbParseErrorToValue(Expression arg0, Expression arg1) { + super("jsonb_parse_error_to_value", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbParseErrorToValue withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbParseErrorToValue(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseErrorToValue(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnull.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnull.java new file mode 100644 index 0000000000..d7aa47d04f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnull.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_notnull'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseNotnull extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParseNotnull(Expression arg) { + super("jsonb_parse_notnull", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParseNotnull withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParseNotnull(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseNotnull(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToInvalid.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToInvalid.java new file mode 100644 index 0000000000..394cc1ef71 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToInvalid.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_notnull_error_to_invalid'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseNotnullErrorToInvalid extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParseNotnullErrorToInvalid(Expression arg) { + super("jsonb_parse_notnull_error_to_invalid", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParseNotnullErrorToInvalid withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParseNotnullErrorToInvalid(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseNotnullErrorToInvalid(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToValue.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToValue.java new file mode 100644 index 0000000000..ab21e7666f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNotnullErrorToValue.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_notnull_error_to_value'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseNotnullErrorToValue extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbParseNotnullErrorToValue(Expression arg0, Expression arg1) { + super("jsonb_parse_notnull_error_to_value", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbParseNotnullErrorToValue withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbParseNotnullErrorToValue(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseNotnullErrorToValue(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullable.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullable.java new file mode 100644 index 0000000000..a1ce3d9228 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullable.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_nullable'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseNullable extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParseNullable(Expression arg) { + super("jsonb_parse_nullable", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParseNullable withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParseNullable(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseNullable(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToInvalid.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToInvalid.java new file mode 100644 index 0000000000..3e225d6421 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToInvalid.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_nullable_error_to_invalid'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseNullableErrorToInvalid extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParseNullableErrorToInvalid(Expression arg) { + super("jsonb_parse_nullable_error_to_invalid", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParseNullableErrorToInvalid withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParseNullableErrorToInvalid(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseNullableErrorToInvalid(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToNull.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToNull.java new file mode 100644 index 0000000000..422549d16f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToNull.java @@ -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.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_nullable_error_to_null'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseNullableErrorToNull extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 argument. + */ + public JsonbParseNullableErrorToNull(Expression arg) { + super("jsonb_parse_nullable_error_to_null", arg); + } + + /** + * withChildren. + */ + @Override + public JsonbParseNullableErrorToNull withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbParseNullableErrorToNull(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseNullableErrorToNull(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToValue.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToValue.java new file mode 100644 index 0000000000..9bb94c0d89 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbParseNullableErrorToValue.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.JsonType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_parse_nullable_error_to_value'. This class is generated by GenerateScalarFunction. + */ +public class JsonbParseNullableErrorToValue extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(JsonType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbParseNullableErrorToValue(Expression arg0, Expression arg1) { + super("jsonb_parse_nullable_error_to_value", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbParseNullableErrorToValue withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbParseNullableErrorToValue(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbParseNullableErrorToValue(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbType.java new file mode 100644 index 0000000000..cb1a1ff1f9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbType.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.JsonType; +import org.apache.doris.nereids.types.StringType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_type'. This class is generated by GenerateScalarFunction. + */ +public class JsonbType extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(StringType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public JsonbType(Expression arg0, Expression arg1) { + super("jsonb_type", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public JsonbType withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new JsonbType(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbType(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Least.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Least.java new file mode 100644 index 0000000000..60c94b8fd3 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Least.java @@ -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.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.DateTimeType; +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 'least'. This class is generated by GenerateScalarFunction. + */ +public class Least extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + 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(DecimalV2Type.MAX).varArgs(DecimalV2Type.MAX), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).varArgs(StringType.INSTANCE) + ); + + /** + * constructor with 1 or more arguments. + */ + public Least(Expression arg, Expression... varArgs) { + super("least", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public Least withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new Least(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLeast(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Left.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Left.java new file mode 100644 index 0000000000..3fb0f7ff3c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Left.java @@ -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.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 'left'. This class is generated by GenerateScalarFunction. + */ +public class Left extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Left(Expression arg0, Expression arg1) { + super("left", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Left withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Left(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLeft(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Length.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Length.java new file mode 100644 index 0000000000..b81ca07a11 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Length.java @@ -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 'length'. This class is generated by GenerateScalarFunction. + */ +public class Length extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Length(Expression arg) { + super("length", arg); + } + + /** + * withChildren. + */ + @Override + public Length withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Length(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLength(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ln.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ln.java new file mode 100644 index 0000000000..e4bfe82b12 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ln.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.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 'ln'. This class is generated by GenerateScalarFunction. + */ +public class Ln extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Ln(Expression arg) { + super("ln", arg); + } + + /** + * withChildren. + */ + @Override + public Ln withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Ln(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLn(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTime.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTime.java new file mode 100644 index 0000000000..4d2c29b3a1 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTime.java @@ -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 'localtime'. This class is generated by GenerateScalarFunction. + */ +public class LocalTime extends DateTimeWithPrecision + implements ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE) + ); + + /** + * constructor with 0 argument. + */ + public LocalTime() { + super("localtime"); + } + + /** + * constructor with 1 argument. + */ + public LocalTime(Expression arg) { + super("localtime", arg); + } + + /** + * withChildren. + */ + @Override + public LocalTime withChildren(List children) { + Preconditions.checkArgument(children.size() == 0 + || children.size() == 1); + if (children.isEmpty() && arity() == 0) { + return this; + } else { + return new LocalTime(children.get(0)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLocalTime(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTimestamp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTimestamp.java new file mode 100644 index 0000000000..e84ab28e27 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/LocalTimestamp.java @@ -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 'localtimestamp'. This class is generated by GenerateScalarFunction. + */ +public class LocalTimestamp extends DateTimeWithPrecision + implements ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE) + ); + + /** + * constructor with 0 argument. + */ + public LocalTimestamp() { + super("localtimestamp"); + } + + /** + * constructor with 1 argument. + */ + public LocalTimestamp(Expression arg) { + super("localtimestamp", arg); + } + + /** + * withChildren. + */ + @Override + public LocalTimestamp withChildren(List children) { + Preconditions.checkArgument(children.size() == 0 + || children.size() == 1); + if (children.isEmpty() && arity() == 0) { + return this; + } else { + return new LocalTimestamp(children.get(0)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLocalTimestamp(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Locate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Locate.java new file mode 100644 index 0000000000..bc5db10d8d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Locate.java @@ -0,0 +1,86 @@ +// 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.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 'locate'. This class is generated by GenerateScalarFunction. + */ +public class Locate extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE) + .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE) + .args(StringType.INSTANCE, StringType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Locate(Expression arg0, Expression arg1) { + super("locate", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public Locate(Expression arg0, Expression arg1, Expression arg2) { + super("locate", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public Locate withChildren(List children) { + Preconditions.checkArgument(children.size() == 2 + || children.size() == 3); + if (children.size() == 2) { + return new Locate(children.get(0), children.get(1)); + } else { + return new Locate(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLocate(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log.java new file mode 100644 index 0000000000..5077b70218 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DoubleType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'log'. This class is generated by GenerateScalarFunction. + */ +public class Log extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Log(Expression arg0, Expression arg1) { + super("log", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Log withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Log(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLog(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log10.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log10.java new file mode 100644 index 0000000000..a593dd7cdf --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log10.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.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 'log10'. This class is generated by GenerateScalarFunction. + */ +public class Log10 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Log10(Expression arg) { + super("log10", arg); + } + + /** + * withChildren. + */ + @Override + public Log10 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Log10(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLog10(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log2.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log2.java new file mode 100644 index 0000000000..19ad4d21e0 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Log2.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.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 'log2'. This class is generated by GenerateScalarFunction. + */ +public class Log2 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Log2(Expression arg) { + super("log2", arg); + } + + /** + * withChildren. + */ + @Override + public Log2 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Log2(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLog2(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lower.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lower.java new file mode 100644 index 0000000000..1068272296 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lower.java @@ -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.UnaryExpression; +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 'lower'. This class is generated by GenerateScalarFunction. + */ +public class Lower extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Lower(Expression arg) { + super("lower", arg); + } + + /** + * withChildren. + */ + @Override + public Lower withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Lower(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLower(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lpad.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lpad.java new file mode 100644 index 0000000000..fb5a12742e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Lpad.java @@ -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.TernaryExpression; +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 'lpad'. This class is generated by GenerateScalarFunction. + */ +public class Lpad extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, IntegerType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public Lpad(Expression arg0, Expression arg1, Expression arg2) { + super("lpad", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public Lpad withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new Lpad(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLpad(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ltrim.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ltrim.java new file mode 100644 index 0000000000..90ab3534fb --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ltrim.java @@ -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.UnaryExpression; +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 'ltrim'. This class is generated by GenerateScalarFunction. + */ +public class Ltrim extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Ltrim(Expression arg) { + super("ltrim", arg); + } + + /** + * withChildren. + */ + @Override + public Ltrim withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Ltrim(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitLtrim(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MakeDate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MakeDate.java new file mode 100644 index 0000000000..1d1b573fc6 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MakeDate.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DateType; +import org.apache.doris.nereids.types.IntegerType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'makedate'. This class is generated by GenerateScalarFunction. + */ +public class MakeDate extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateType.INSTANCE).args(IntegerType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public MakeDate(Expression arg0, Expression arg1) { + super("makedate", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public MakeDate withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new MakeDate(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMakeDate(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5.java new file mode 100644 index 0000000000..77e0a26989 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5.java @@ -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.UnaryExpression; +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 'md5'. This class is generated by GenerateScalarFunction. + */ +public class Md5 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Md5(Expression arg) { + super("md5", arg); + } + + /** + * withChildren. + */ + @Override + public Md5 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Md5(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMd5(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5Sum.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5Sum.java new file mode 100644 index 0000000000..5fb79f6654 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Md5Sum.java @@ -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 'md5sum'. This class is generated by GenerateScalarFunction. + */ +public class Md5Sum extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(StringType.INSTANCE) + ); + + /** + * constructor with 1 or more arguments. + */ + public Md5Sum(Expression arg, Expression... varArgs) { + super("md5sum", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public Md5Sum withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new Md5Sum(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMd5Sum(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java new file mode 100644 index 0000000000..8749892774 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java @@ -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 'minute'. This class is generated by GenerateScalarFunction. + */ +public class Minute extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Minute(Expression arg) { + super("minute", arg); + } + + /** + * withChildren. + */ + @Override + public Minute withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Minute(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMinute(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java new file mode 100644 index 0000000000..dedc4c7afe --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java @@ -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 'minute_ceil'. This class is generated by GenerateScalarFunction. + */ +public class MinuteCeil extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE) + .args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public MinuteCeil(Expression arg) { + super("minute_ceil", arg); + } + + /** + * constructor with 2 arguments. + */ + public MinuteCeil(Expression arg0, Expression arg1) { + super("minute_ceil", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public MinuteCeil(Expression arg0, Expression arg1, Expression arg2) { + super("minute_ceil", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public MinuteCeil withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new MinuteCeil(children.get(0)); + } else if (children.size() == 2) { + return new MinuteCeil(children.get(0), children.get(1)); + } else { + return new MinuteCeil(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMinuteCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java new file mode 100644 index 0000000000..e999d6193a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java @@ -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 'minute_floor'. This class is generated by GenerateScalarFunction. + */ +public class MinuteFloor extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE) + .args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public MinuteFloor(Expression arg) { + super("minute_floor", arg); + } + + /** + * constructor with 2 arguments. + */ + public MinuteFloor(Expression arg0, Expression arg1) { + super("minute_floor", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public MinuteFloor(Expression arg0, Expression arg1, Expression arg2) { + super("minute_floor", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public MinuteFloor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new MinuteFloor(children.get(0)); + } else if (children.size() == 2) { + return new MinuteFloor(children.get(0), children.get(1)); + } else { + return new MinuteFloor(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMinuteFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinutesDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinutesDiff.java new file mode 100644 index 0000000000..d01d84b00c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinutesDiff.java @@ -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 'minutes_diff'. This class is generated by GenerateScalarFunction. + */ +public class MinutesDiff extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 MinutesDiff(Expression arg0, Expression arg1) { + super("minutes_diff", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public MinutesDiff withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new MinutesDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMinutesDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MoneyFormat.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MoneyFormat.java new file mode 100644 index 0000000000..bf0963b883 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MoneyFormat.java @@ -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.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.LargeIntType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'money_format'. This class is generated by GenerateScalarFunction. + */ +public class MoneyFormat extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(BigIntType.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(LargeIntType.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DoubleType.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DecimalV2Type.MAX) + ); + + /** + * constructor with 1 argument. + */ + public MoneyFormat(Expression arg) { + super("money_format", arg); + } + + /** + * withChildren. + */ + @Override + public MoneyFormat withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new MoneyFormat(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMoneyFormat(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java new file mode 100644 index 0000000000..0301e4b39a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java @@ -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 'month'. This class is generated by GenerateScalarFunction. + */ +public class Month extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Month(Expression arg) { + super("month", arg); + } + + /** + * withChildren. + */ + @Override + public Month withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Month(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMonth(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java new file mode 100644 index 0000000000..5c4eb8719c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java @@ -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 'month_ceil'. This class is generated by GenerateScalarFunction. + */ +public class MonthCeil extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 MonthCeil(Expression arg) { + super("month_ceil", arg); + } + + /** + * constructor with 2 arguments. + */ + public MonthCeil(Expression arg0, Expression arg1) { + super("month_ceil", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public MonthCeil(Expression arg0, Expression arg1, Expression arg2) { + super("month_ceil", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public MonthCeil withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new MonthCeil(children.get(0)); + } else if (children.size() == 2) { + return new MonthCeil(children.get(0), children.get(1)); + } else { + return new MonthCeil(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMonthCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java new file mode 100644 index 0000000000..a414771b07 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java @@ -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 'month_floor'. This class is generated by GenerateScalarFunction. + */ +public class MonthFloor extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 MonthFloor(Expression arg) { + super("month_floor", arg); + } + + /** + * constructor with 2 arguments. + */ + public MonthFloor(Expression arg0, Expression arg1) { + super("month_floor", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public MonthFloor(Expression arg0, Expression arg1, Expression arg2) { + super("month_floor", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public MonthFloor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new MonthFloor(children.get(0)); + } else if (children.size() == 2) { + return new MonthFloor(children.get(0), children.get(1)); + } else { + return new MonthFloor(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMonthFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthName.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthName.java new file mode 100644 index 0000000000..680ae0a91a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthName.java @@ -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 'monthname'. This class is generated by GenerateScalarFunction. + */ +public class MonthName extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 MonthName(Expression arg) { + super("monthname", arg); + } + + /** + * withChildren. + */ + @Override + public MonthName withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new MonthName(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMonthName(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsDiff.java new file mode 100644 index 0000000000..20d6f3847e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsDiff.java @@ -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 'months_diff'. This class is generated by GenerateScalarFunction. + */ +public class MonthsDiff extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 MonthsDiff(Expression arg0, Expression arg1) { + super("months_diff", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public MonthsDiff withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new MonthsDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMonthsDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash332.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash332.java new file mode 100644 index 0000000000..18bfd2451c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash332.java @@ -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.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.IntegerType; +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 'murmur_hash3_32'. This class is generated by GenerateScalarFunction. + */ +public class MurmurHash332 extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).varArgs(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).varArgs(StringType.INSTANCE) + ); + + /** + * constructor with 1 or more arguments. + */ + public MurmurHash332(Expression arg, Expression... varArgs) { + super("murmur_hash3_32", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public MurmurHash332 withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new MurmurHash332(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMurmurHash332(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash364.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash364.java new file mode 100644 index 0000000000..bdd18833bd --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MurmurHash364.java @@ -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.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.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 'murmur_hash3_64'. This class is generated by GenerateScalarFunction. + */ +public class MurmurHash364 extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).varArgs(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BigIntType.INSTANCE).varArgs(StringType.INSTANCE) + ); + + /** + * constructor with 1 or more arguments. + */ + public MurmurHash364(Expression arg, Expression... varArgs) { + super("murmur_hash3_64", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public MurmurHash364 withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new MurmurHash364(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitMurmurHash364(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Negative.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Negative.java new file mode 100644 index 0000000000..16d7c69268 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Negative.java @@ -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.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 com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'negative'. This class is generated by GenerateScalarFunction. + */ +public class Negative extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable, DecimalSamePrecision { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), + FunctionSignature.ret(DecimalV2Type.MAX).args(DecimalV2Type.MAX) + ); + + /** + * constructor with 1 argument. + */ + public Negative(Expression arg) { + super("negative", arg); + } + + /** + * withChildren. + */ + @Override + public Negative withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Negative(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitNegative(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NotNullOrEmpty.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NotNullOrEmpty.java new file mode 100644 index 0000000000..c02c3892c6 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NotNullOrEmpty.java @@ -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.BooleanType; +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 'not_null_or_empty'. This class is generated by GenerateScalarFunction. + */ +public class NotNullOrEmpty extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BooleanType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public NotNullOrEmpty(Expression arg) { + super("not_null_or_empty", arg); + } + + /** + * withChildren. + */ + @Override + public NotNullOrEmpty withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new NotNullOrEmpty(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitNotNullOrEmpty(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Now.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Now.java new file mode 100644 index 0000000000..e8d603262d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Now.java @@ -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 'now'. This class is generated by GenerateScalarFunction. + */ +public class Now extends DateTimeWithPrecision + implements ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE) + ); + + /** + * constructor with 0 argument. + */ + public Now() { + super("now"); + } + + /** + * constructor with 1 argument. + */ + public Now(Expression arg) { + super("now", arg); + } + + /** + * withChildren. + */ + @Override + public Now withChildren(List children) { + Preconditions.checkArgument(children.size() == 0 + || children.size() == 1); + if (children.isEmpty() && arity() == 0) { + return this; + } else { + return new Now(children.get(0)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitNow(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java new file mode 100644 index 0000000000..6f2d426684 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java @@ -0,0 +1,97 @@ +// 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.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 com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'nullif'. This class is generated by GenerateScalarFunction. + */ +public class NullIf extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(BooleanType.INSTANCE, BooleanType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE, TinyIntType.INSTANCE), + FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE, SmallIntType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE, BigIntType.INSTANCE), + FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE, LargeIntType.INSTANCE), + FunctionSignature.ret(FloatType.INSTANCE).args(FloatType.INSTANCE, FloatType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE), + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, DateType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DecimalV2Type.MAX).args(DecimalV2Type.MAX, DecimalV2Type.MAX), + 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 NullIf(Expression arg0, Expression arg1) { + super("nullif", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public NullIf withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new NullIf(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitNullIf(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullOrEmpty.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullOrEmpty.java new file mode 100644 index 0000000000..f6d2ee50b3 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullOrEmpty.java @@ -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.BooleanType; +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 'null_or_empty'. This class is generated by GenerateScalarFunction. + */ +public class NullOrEmpty extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BooleanType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public NullOrEmpty(Expression arg) { + super("null_or_empty", arg); + } + + /** + * withChildren. + */ + @Override + public NullOrEmpty withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new NullOrEmpty(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitNullOrEmpty(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java new file mode 100644 index 0000000000..410cb97b75 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java @@ -0,0 +1,109 @@ +// 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.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 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 com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'nvl'. This class is generated by GenerateScalarFunction. + */ +public class Nvl extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(BooleanType.INSTANCE, BooleanType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE, TinyIntType.INSTANCE), + FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE, SmallIntType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE, BigIntType.INSTANCE), + FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE, LargeIntType.INSTANCE), + FunctionSignature.ret(FloatType.INSTANCE).args(FloatType.INSTANCE, FloatType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, DateType.INSTANCE), + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DecimalV2Type.MAX).args(DecimalV2Type.MAX, DecimalV2Type.MAX), + FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE), + 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 Nvl(Expression arg0, Expression arg1) { + super("nvl", arg0, arg1); + } + + /** + * custom compute nullable. + */ + @Override + public boolean nullable() { + return child(0).nullable() && child(1).nullable(); + } + + /** + * withChildren. + */ + @Override + public Nvl withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Nvl(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitNvl(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ParseUrl.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ParseUrl.java new file mode 100644 index 0000000000..c922e77d61 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ParseUrl.java @@ -0,0 +1,86 @@ +// 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 'parse_url'. This class is generated by GenerateScalarFunction. + */ +public class ParseUrl extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public ParseUrl(Expression arg0, Expression arg1) { + super("parse_url", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public ParseUrl(Expression arg0, Expression arg1, Expression arg2) { + super("parse_url", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public ParseUrl withChildren(List children) { + Preconditions.checkArgument(children.size() == 2 + || children.size() == 3); + if (children.size() == 2) { + return new ParseUrl(children.get(0), children.get(1)); + } else { + return new ParseUrl(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitParseUrl(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pi.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pi.java new file mode 100644 index 0000000000..ed1e5c85b3 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pi.java @@ -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.DoubleType; + +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'pi'. This class is generated by GenerateScalarFunction. + */ +public class Pi extends ScalarFunction + implements LeafExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public Pi() { + super("pi"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitPi(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pmod.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pmod.java new file mode 100644 index 0000000000..5609420132 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pmod.java @@ -0,0 +1,70 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.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 'pmod'. This class is generated by GenerateScalarFunction. + */ +public class Pmod extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE, BigIntType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Pmod(Expression arg0, Expression arg1) { + super("pmod", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Pmod withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Pmod(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitPmod(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Positive.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Positive.java new file mode 100644 index 0000000000..411258682e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Positive.java @@ -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.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 com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'positive'. This class is generated by GenerateScalarFunction. + */ +public class Positive extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable, DecimalSamePrecision { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), + FunctionSignature.ret(DecimalV2Type.MAX).args(DecimalV2Type.MAX) + ); + + /** + * constructor with 1 argument. + */ + public Positive(Expression arg) { + super("positive", arg); + } + + /** + * withChildren. + */ + @Override + public Positive withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Positive(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitPositive(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pow.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pow.java new file mode 100644 index 0000000000..e1b5fffd3a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Pow.java @@ -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.DoubleType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'pow'. This class is generated by GenerateScalarFunction. + */ +public class Pow extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Pow(Expression arg0, Expression arg1) { + super("pow", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Pow withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Pow(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitPow(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Power.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Power.java new file mode 100644 index 0000000000..8cc8e1f5e7 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Power.java @@ -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.DoubleType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'power'. This class is generated by GenerateScalarFunction. + */ +public class Power extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Power(Expression arg0, Expression arg1) { + super("power", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Power withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Power(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitPower(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/QuantilePercent.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/QuantilePercent.java new file mode 100644 index 0000000000..c4b96e8aac --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/QuantilePercent.java @@ -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.DoubleType; +import org.apache.doris.nereids.types.FloatType; +import org.apache.doris.nereids.types.QuantileStateType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'quantile_percent'. This class is generated by GenerateScalarFunction. + */ +public class QuantilePercent extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(QuantileStateType.INSTANCE, FloatType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public QuantilePercent(Expression arg0, Expression arg1) { + super("quantile_percent", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public QuantilePercent withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new QuantilePercent(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitQuantilePercent(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java new file mode 100644 index 0000000000..e2d9f34a8c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java @@ -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 'quarter'. This class is generated by GenerateScalarFunction. + */ +public class Quarter extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Quarter(Expression arg) { + super("quarter", arg); + } + + /** + * withChildren. + */ + @Override + public Quarter withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Quarter(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitQuarter(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Radians.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Radians.java new file mode 100644 index 0000000000..8f37005154 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Radians.java @@ -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 'radians'. This class is generated by GenerateScalarFunction. + */ +public class Radians extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Radians(Expression arg) { + super("radians", arg); + } + + /** + * withChildren. + */ + @Override + public Radians withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Radians(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRadians(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Random.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Random.java new file mode 100644 index 0000000000..712994e52d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Random.java @@ -0,0 +1,92 @@ +// 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.DoubleType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'random'. This class is generated by GenerateScalarFunction. + */ +public class Random extends ScalarFunction + implements ExplicitlyCastableSignature { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(), + FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE) + ); + + /** + * constructor with 0 argument. + */ + public Random() { + super("random"); + } + + /** + * constructor with 1 argument. + */ + public Random(Expression arg) { + super("random", arg); + } + + /** + * custom compute nullable. + */ + @Override + public boolean nullable() { + if (arity() > 0) { + return children().stream().anyMatch(Expression::nullable); + } else { + return false; + } + } + + /** + * withChildren. + */ + @Override + public Random withChildren(List children) { + Preconditions.checkArgument(children.size() == 0 + || children.size() == 1); + if (children.isEmpty() && arity() == 0) { + return this; + } else { + return new Random(children.get(0)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRandom(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpExtract.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpExtract.java new file mode 100644 index 0000000000..639831abff --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpExtract.java @@ -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.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.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'regexp_extract'. This class is generated by GenerateScalarFunction. + */ +public class RegexpExtract extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT, BigIntType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, StringType.INSTANCE, BigIntType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public RegexpExtract(Expression arg0, Expression arg1, Expression arg2) { + super("regexp_extract", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public RegexpExtract withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new RegexpExtract(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRegexpExtract(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpReplace.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpReplace.java new file mode 100644 index 0000000000..4486fb680c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RegexpReplace.java @@ -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.TernaryExpression; +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 'regexp_replace'. This class is generated by GenerateScalarFunction. + */ +public class RegexpReplace extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public RegexpReplace(Expression arg0, Expression arg1, Expression arg2) { + super("regexp_replace", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public RegexpReplace withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new RegexpReplace(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRegexpReplace(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Repeat.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Repeat.java new file mode 100644 index 0000000000..ab7861565a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Repeat.java @@ -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.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 'repeat'. This class is generated by GenerateScalarFunction. + */ +public class Repeat extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Repeat(Expression arg0, Expression arg1) { + super("repeat", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Repeat withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Repeat(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRepeat(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Replace.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Replace.java new file mode 100644 index 0000000000..77d94eb487 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Replace.java @@ -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.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; +import org.apache.doris.nereids.trees.expressions.shape.TernaryExpression; +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 'replace'. This class is generated by GenerateScalarFunction. + */ +public class Replace extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public Replace(Expression arg0, Expression arg1, Expression arg2) { + super("replace", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public Replace withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new Replace(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitReplace(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Reverse.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Reverse.java new file mode 100644 index 0000000000..e55069800d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Reverse.java @@ -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.UnaryExpression; +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 'reverse'. This class is generated by GenerateScalarFunction. + */ +public class Reverse extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Reverse(Expression arg) { + super("reverse", arg); + } + + /** + * withChildren. + */ + @Override + public Reverse withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Reverse(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitReverse(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Right.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Right.java new file mode 100644 index 0000000000..e78398403c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Right.java @@ -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.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 'right'. This class is generated by GenerateScalarFunction. + */ +public class Right extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Right(Expression arg0, Expression arg1) { + super("right", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Right withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Right(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRight(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java new file mode 100644 index 0000000000..0f03c7dcea --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java @@ -0,0 +1,82 @@ +// 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.DoubleType; +import org.apache.doris.nereids.types.IntegerType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'round'. This class is generated by GenerateScalarFunction. + */ +public class Round extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE), + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Round(Expression arg) { + super("round", arg); + } + + /** + * constructor with 2 arguments. + */ + public Round(Expression arg0, Expression arg1) { + super("round", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Round withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2); + if (children.size() == 1) { + return new Round(children.get(0)); + } else { + return new Round(children.get(0), children.get(1)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRound(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rpad.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rpad.java new file mode 100644 index 0000000000..31b041839d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rpad.java @@ -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.TernaryExpression; +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 'rpad'. This class is generated by GenerateScalarFunction. + */ +public class Rpad extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, IntegerType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public Rpad(Expression arg0, Expression arg1, Expression arg2) { + super("rpad", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public Rpad withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new Rpad(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRpad(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rtrim.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rtrim.java new file mode 100644 index 0000000000..6ddf772eb9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Rtrim.java @@ -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.UnaryExpression; +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 'rtrim'. This class is generated by GenerateScalarFunction. + */ +public class Rtrim extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Rtrim(Expression arg) { + super("rtrim", arg); + } + + /** + * withChildren. + */ + @Override + public Rtrim withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Rtrim(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitRtrim(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ScalarFunction.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ScalarFunction.java index fec7e8b99b..f5bb5e8142 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ScalarFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ScalarFunction.java @@ -17,14 +17,197 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.catalog.ScalarType; +import org.apache.doris.catalog.Type; +import org.apache.doris.common.Config; +import org.apache.doris.common.Pair; +import org.apache.doris.nereids.annotation.Developing; import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.functions.BoundFunction; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignature; +import org.apache.doris.nereids.trees.expressions.functions.DecimalSamePrecision; +import org.apache.doris.nereids.trees.expressions.functions.DecimalStddevPrecision; +import org.apache.doris.nereids.trees.expressions.functions.DecimalWiderPrecision; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.ArrayType; +import org.apache.doris.nereids.types.DataType; +import org.apache.doris.nereids.types.DateTimeV2Type; +import org.apache.doris.nereids.types.DecimalV2Type; +import org.apache.doris.nereids.types.DecimalV3Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; +import org.apache.doris.nereids.util.ResponsibilityChain; + +import com.google.common.base.Suppliers; + +import java.util.List; +import java.util.function.BiFunction; +import java.util.function.Supplier; /** * The function which consume zero or more arguments in a row and product one value. */ -public abstract class ScalarFunction extends BoundFunction { +public abstract class ScalarFunction extends BoundFunction implements ComputeSignature { + @Developing("this field will move to BoundFunction, when we support compute signature for AggregateFunction") + private final Supplier signatureCache = Suppliers.memoize(() -> { + // first step: find the candidate signature in the signature list + FunctionSignature matchedSignature = searchSignature(); + // second step: change the signature, e.g. fill precision for decimal v2 + return computeSignature(matchedSignature); + }); + public ScalarFunction(String name, Expression... arguments) { super(name, arguments); } + + public ScalarFunction(String name, List arguments) { + super(name, arguments); + } + + public FunctionSignature getSignature() { + return signatureCache.get(); + } + + protected FunctionSignature computeSignature(FunctionSignature signature) { + // NOTE: + // this computed chain only process the common cases. + // If you want to add some common cases to here, please separate the process code + // to the other methods and add to this chain. + // If you want to add some special cases, please override this method in the special + // function class, like 'If' function and 'Substring' function. + return ComputeSignatureChain.from(signature, getArguments()) + .then(this::computePrecisionForDatetimeV2) + .then(this::upgradeDateOrDateTimeToV2) + .then(this::upgradeDecimalV2ToV3) + .then(this::computePrecisionForDecimal) + .then(this::dynamicComputePropertiesOfArray) + .get(); + } + + @Override + @Developing("this method will move to BoundFunction, when we support compute signature for AggregateFunction") + public final List expectedInputTypes() { + return ComputeSignature.super.expectedInputTypes(); + } + + @Override + @Developing("this method will move to BoundFunction, when we support compute signature for AggregateFunction") + public final DataType getDataType() { + return ComputeSignature.super.getDataType(); + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitScalarFunction(this, context); + } + + private final FunctionSignature computePrecisionForDatetimeV2( + FunctionSignature signature, List arguments) { + + // fill for arguments type + signature = signature.withArgumentTypes(arguments, (sigArgType, realArgType) -> { + if (sigArgType instanceof DateTimeV2Type && realArgType.getDataType() instanceof DateTimeV2Type) { + return realArgType.getDataType(); + } + return sigArgType; + }); + + // fill for return type + if (signature.returnType instanceof DateTimeV2Type) { + Integer maxScale = signature.argumentsTypes.stream() + .filter(DateTimeV2Type.class::isInstance) + .map(t -> ((DateTimeV2Type) t).getScale()) + .reduce(Math::max) + .orElse(((DateTimeV2Type) signature.returnType).getScale()); + signature = signature.withReturnType(DateTimeV2Type.of(maxScale)); + } + + return signature; + } + + private final FunctionSignature upgradeDateOrDateTimeToV2( + FunctionSignature signature, List arguments) { + DataType returnType = signature.returnType; + Type type = returnType.toCatalogDataType(); + if ((type.isDate() || type.isDatetime()) && Config.enable_date_conversion) { + Type legacyReturnType = ScalarType.getDefaultDateType(returnType.toCatalogDataType()); + signature = signature.withReturnType(DataType.fromCatalogType(legacyReturnType)); + } + return signature; + } + + @Developing + private final FunctionSignature computePrecisionForDecimal( + FunctionSignature signature, List arguments) { + if (signature.returnType instanceof DecimalV3Type || signature.returnType instanceof DecimalV2Type) { + if (this instanceof DecimalSamePrecision) { + signature = signature.withReturnType(signature.argumentsTypes.get(0)); + } else if (this instanceof DecimalWiderPrecision) { + ScalarType widerType = ScalarType.createDecimalV3Type(ScalarType.MAX_DECIMAL128_PRECISION, + ((ScalarType) signature.argumentsTypes.get(0).toCatalogDataType()).getScalarScale()); + signature = signature.withReturnType(DataType.fromCatalogType(widerType)); + } else if (this instanceof DecimalStddevPrecision) { + // for all stddev function, use decimal(38,9) as computing result + ScalarType stddevDecimalType = ScalarType.createDecimalV3Type(ScalarType.MAX_DECIMAL128_PRECISION, + DecimalStddevPrecision.STDDEV_DECIMAL_SCALE); + signature = signature.withReturnType(DataType.fromCatalogType(stddevDecimalType)); + } + } + + return signature; + } + + private final FunctionSignature upgradeDecimalV2ToV3( + FunctionSignature signature, List arguments) { + DataType returnType = signature.returnType; + Type type = returnType.toCatalogDataType(); + if (type.isDecimalV2() && Config.enable_decimal_conversion && Config.enable_decimalv3) { + Type v3Type = ScalarType.createDecimalV3Type(type.getPrecision(), ((ScalarType) type).getScalarScale()); + signature = signature.withReturnType(DataType.fromCatalogType(v3Type)); + } + return signature; + } + + private final FunctionSignature dynamicComputePropertiesOfArray( + FunctionSignature signature, List arguments) { + if (!(signature.returnType instanceof ArrayType)) { + return signature; + } + + // TODO: compute array(...) function's itemType + + // fill item type by the type of first item + ArrayType arrayType = (ArrayType) signature.returnType; + + // fill containsNull if any array argument contains null + boolean containsNull = signature.argumentsTypes + .stream() + .filter(argType -> argType instanceof ArrayType) + .map(ArrayType.class::cast) + .anyMatch(ArrayType::containsNull); + return signature.withReturnType( + ArrayType.of(arrayType.getItemType(), arrayType.containsNull() || containsNull)); + } + + static class ComputeSignatureChain { + private ResponsibilityChain>> computeChain; + + public ComputeSignatureChain(ResponsibilityChain>> computeChain) { + this.computeChain = computeChain; + } + + public static ComputeSignatureChain from(FunctionSignature signature, List arguments) { + return new ComputeSignatureChain(ResponsibilityChain.from(Pair.of(signature, arguments))); + } + + public ComputeSignatureChain then( + BiFunction, FunctionSignature> computeFunction) { + computeChain.then(pair -> Pair.of(computeFunction.apply(pair.first, pair.second), pair.second)); + return this; + } + + public FunctionSignature get() { + return computeChain.get().first; + } + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java new file mode 100644 index 0000000000..df2d9a1d5a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java @@ -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 'second'. This class is generated by GenerateScalarFunction. + */ +public class Second extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Second(Expression arg) { + super("second", arg); + } + + /** + * withChildren. + */ + @Override + public Second withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Second(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSecond(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java new file mode 100644 index 0000000000..d7837a9dd9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java @@ -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 'second_ceil'. This class is generated by GenerateScalarFunction. + */ +public class SecondCeil extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE) + .args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public SecondCeil(Expression arg) { + super("second_ceil", arg); + } + + /** + * constructor with 2 arguments. + */ + public SecondCeil(Expression arg0, Expression arg1) { + super("second_ceil", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public SecondCeil(Expression arg0, Expression arg1, Expression arg2) { + super("second_ceil", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public SecondCeil withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new SecondCeil(children.get(0)); + } else if (children.size() == 2) { + return new SecondCeil(children.get(0), children.get(1)); + } else { + return new SecondCeil(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSecondCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java new file mode 100644 index 0000000000..10bdb1c362 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java @@ -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 'second_floor'. This class is generated by GenerateScalarFunction. + */ +public class SecondFloor extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.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(DateTimeV2Type.INSTANCE) + .args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public SecondFloor(Expression arg) { + super("second_floor", arg); + } + + /** + * constructor with 2 arguments. + */ + public SecondFloor(Expression arg0, Expression arg1) { + super("second_floor", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public SecondFloor(Expression arg0, Expression arg1, Expression arg2) { + super("second_floor", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public SecondFloor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new SecondFloor(children.get(0)); + } else if (children.size() == 2) { + return new SecondFloor(children.get(0), children.get(1)); + } else { + return new SecondFloor(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSecondFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondsDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondsDiff.java new file mode 100644 index 0000000000..8d46ebc74f --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondsDiff.java @@ -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 'seconds_diff'. This class is generated by GenerateScalarFunction. + */ +public class SecondsDiff extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 SecondsDiff(Expression arg0, Expression arg1) { + super("seconds_diff", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public SecondsDiff withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new SecondsDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSecondsDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sign.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sign.java new file mode 100644 index 0000000000..29084b5544 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sign.java @@ -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.DoubleType; +import org.apache.doris.nereids.types.TinyIntType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'sign'. This class is generated by GenerateScalarFunction. + */ +public class Sign extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(TinyIntType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Sign(Expression arg) { + super("sign", arg); + } + + /** + * withChildren. + */ + @Override + public Sign withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Sign(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSign(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sin.java new file mode 100644 index 0000000000..aa66366e79 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sin.java @@ -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 'sin'. This class is generated by GenerateScalarFunction. + */ +public class Sin extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Sin(Expression arg) { + super("sin", arg); + } + + /** + * withChildren. + */ + @Override + public Sin withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Sin(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSin(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sleep.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sleep.java new file mode 100644 index 0000000000..b9d7a36f7e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sleep.java @@ -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.BooleanType; +import org.apache.doris.nereids.types.IntegerType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'sleep'. This class is generated by GenerateScalarFunction. + */ +public class Sleep extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(IntegerType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Sleep(Expression arg) { + super("sleep", arg); + } + + /** + * withChildren. + */ + @Override + public Sleep withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Sleep(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSleep(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3.java new file mode 100644 index 0000000000..9882ee7d9e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3.java @@ -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.UnaryExpression; +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 'sm3'. This class is generated by GenerateScalarFunction. + */ +public class Sm3 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Sm3(Expression arg) { + super("sm3", arg); + } + + /** + * withChildren. + */ + @Override + public Sm3 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Sm3(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSm3(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3sum.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3sum.java new file mode 100644 index 0000000000..1b9e89660c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm3sum.java @@ -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 'sm3sum'. This class is generated by GenerateScalarFunction. + */ +public class Sm3sum extends ScalarFunction + implements ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(StringType.INSTANCE) + ); + + /** + * constructor with 1 or more arguments. + */ + public Sm3sum(Expression arg, Expression... varArgs) { + super("sm3sum", ExpressionUtils.mergeArguments(arg, varArgs)); + } + + /** + * withChildren. + */ + @Override + public Sm3sum withChildren(List children) { + Preconditions.checkArgument(children.size() >= 1); + return new Sm3sum(children.get(0), + children.subList(1, children.size()).toArray(new Expression[0])); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSm3sum(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Decrypt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Decrypt.java new file mode 100644 index 0000000000..9ab0a33618 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Decrypt.java @@ -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 'sm4_decrypt'. This class is generated by GenerateScalarFunction. + */ +public class Sm4Decrypt extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Sm4Decrypt(Expression arg0, Expression arg1) { + super("sm4_decrypt", arg0, arg1); + } + + /** + * constructor with 4 arguments. + */ + public Sm4Decrypt(Expression arg0, Expression arg1, Expression arg2, Expression arg3) { + super("sm4_decrypt", arg0, arg1, arg2, arg3); + } + + /** + * withChildren. + */ + @Override + public Sm4Decrypt withChildren(List children) { + Preconditions.checkArgument(children.size() == 2 + || children.size() == 4); + if (children.size() == 2) { + return new Sm4Decrypt(children.get(0), children.get(1)); + } else { + return new Sm4Decrypt(children.get(0), children.get(1), children.get(2), children.get(3)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSm4Decrypt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Encrypt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Encrypt.java new file mode 100644 index 0000000000..2f2841511d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sm4Encrypt.java @@ -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 'sm4_encrypt'. This class is generated by GenerateScalarFunction. + */ +public class Sm4Encrypt extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Sm4Encrypt(Expression arg0, Expression arg1) { + super("sm4_encrypt", arg0, arg1); + } + + /** + * constructor with 4 arguments. + */ + public Sm4Encrypt(Expression arg0, Expression arg1, Expression arg2, Expression arg3) { + super("sm4_encrypt", arg0, arg1, arg2, arg3); + } + + /** + * withChildren. + */ + @Override + public Sm4Encrypt withChildren(List children) { + Preconditions.checkArgument(children.size() == 2 + || children.size() == 4); + if (children.size() == 2) { + return new Sm4Encrypt(children.get(0), children.get(1)); + } else { + return new Sm4Encrypt(children.get(0), children.get(1), children.get(2), children.get(3)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSm4Encrypt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Space.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Space.java new file mode 100644 index 0000000000..8c5282c52d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Space.java @@ -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.IntegerType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'space'. This class is generated by GenerateScalarFunction. + */ +public class Space extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IntegerType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Space(Expression arg) { + super("space", arg); + } + + /** + * withChildren. + */ + @Override + public Space withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Space(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSpace(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SplitPart.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SplitPart.java new file mode 100644 index 0000000000..e0e6d41eaa --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SplitPart.java @@ -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.TernaryExpression; +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 'split_part'. This class is generated by GenerateScalarFunction. + */ +public class SplitPart extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, StringType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public SplitPart(Expression arg0, Expression arg1, Expression arg2) { + super("split_part", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public SplitPart withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new SplitPart(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSplitPart(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sqrt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sqrt.java new file mode 100644 index 0000000000..d2e850df15 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sqrt.java @@ -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 'sqrt'. This class is generated by GenerateScalarFunction. + */ +public class Sqrt extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Sqrt(Expression arg) { + super("sqrt", arg); + } + + /** + * withChildren. + */ + @Override + public Sqrt withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Sqrt(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSqrt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAstext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAstext.java new file mode 100644 index 0000000000..52810e7b70 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAstext.java @@ -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.UnaryExpression; +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 'st_astext'. This class is generated by GenerateScalarFunction. + */ +public class StAstext extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StAstext(Expression arg) { + super("st_astext", arg); + } + + /** + * withChildren. + */ + @Override + public StAstext withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StAstext(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStAstext(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAswkt.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAswkt.java new file mode 100644 index 0000000000..733b48919d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAswkt.java @@ -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.UnaryExpression; +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 'st_aswkt'. This class is generated by GenerateScalarFunction. + */ +public class StAswkt extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StAswkt(Expression arg) { + super("st_aswkt", arg); + } + + /** + * withChildren. + */ + @Override + public StAswkt withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StAswkt(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStAswkt(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StCircle.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StCircle.java new file mode 100644 index 0000000000..0d72dfe7ae --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StCircle.java @@ -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.DoubleType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'st_circle'. This class is generated by GenerateScalarFunction. + */ +public class StCircle extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(DoubleType.INSTANCE, DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public StCircle(Expression arg0, Expression arg1, Expression arg2) { + super("st_circle", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public StCircle withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new StCircle(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStCircle(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StContains.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StContains.java new file mode 100644 index 0000000000..0337f96a5e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StContains.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.BooleanType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'st_contains'. This class is generated by GenerateScalarFunction. + */ +public class StContains extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 2 arguments. + */ + public StContains(Expression arg0, Expression arg1) { + super("st_contains", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public StContains withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new StContains(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStContains(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StDistanceSphere.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StDistanceSphere.java new file mode 100644 index 0000000000..06fefac20c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StDistanceSphere.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.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 'st_distance_sphere'. This class is generated by GenerateScalarFunction. + */ +public class StDistanceSphere extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE) + .args(DoubleType.INSTANCE, DoubleType.INSTANCE, DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 4 arguments. + */ + public StDistanceSphere(Expression arg0, Expression arg1, Expression arg2, Expression arg3) { + super("st_distance_sphere", arg0, arg1, arg2, arg3); + } + + /** + * withChildren. + */ + @Override + public StDistanceSphere withChildren(List children) { + Preconditions.checkArgument(children.size() == 4); + return new StDistanceSphere(children.get(0), children.get(1), children.get(2), children.get(3)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStDistanceSphere(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeometryfromtext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeometryfromtext.java new file mode 100644 index 0000000000..cfb4e31533 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeometryfromtext.java @@ -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.UnaryExpression; +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 'st_geometryfromtext'. This class is generated by GenerateScalarFunction. + */ +public class StGeometryfromtext extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StGeometryfromtext(Expression arg) { + super("st_geometryfromtext", arg); + } + + /** + * withChildren. + */ + @Override + public StGeometryfromtext withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StGeometryfromtext(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStGeometryfromtext(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeomfromtext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeomfromtext.java new file mode 100644 index 0000000000..9101e8c256 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeomfromtext.java @@ -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.UnaryExpression; +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 'st_geomfromtext'. This class is generated by GenerateScalarFunction. + */ +public class StGeomfromtext extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StGeomfromtext(Expression arg) { + super("st_geomfromtext", arg); + } + + /** + * withChildren. + */ + @Override + public StGeomfromtext withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StGeomfromtext(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStGeomfromtext(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinefromtext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinefromtext.java new file mode 100644 index 0000000000..faabbd8920 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinefromtext.java @@ -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.UnaryExpression; +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 'st_linefromtext'. This class is generated by GenerateScalarFunction. + */ +public class StLinefromtext extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StLinefromtext(Expression arg) { + super("st_linefromtext", arg); + } + + /** + * withChildren. + */ + @Override + public StLinefromtext withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StLinefromtext(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStLinefromtext(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinestringfromtext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinestringfromtext.java new file mode 100644 index 0000000000..f6b1ed63a6 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLinestringfromtext.java @@ -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.UnaryExpression; +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 'st_linestringfromtext'. This class is generated by GenerateScalarFunction. + */ +public class StLinestringfromtext extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StLinestringfromtext(Expression arg) { + super("st_linestringfromtext", arg); + } + + /** + * withChildren. + */ + @Override + public StLinestringfromtext withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StLinestringfromtext(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStLinestringfromtext(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPoint.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPoint.java new file mode 100644 index 0000000000..241de0bba6 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPoint.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DoubleType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'st_point'. This class is generated by GenerateScalarFunction. + */ +public class StPoint extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public StPoint(Expression arg0, Expression arg1) { + super("st_point", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public StPoint withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new StPoint(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStPoint(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolyfromtext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolyfromtext.java new file mode 100644 index 0000000000..b852a94a6b --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolyfromtext.java @@ -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.UnaryExpression; +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 'st_polyfromtext'. This class is generated by GenerateScalarFunction. + */ +public class StPolyfromtext extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StPolyfromtext(Expression arg) { + super("st_polyfromtext", arg); + } + + /** + * withChildren. + */ + @Override + public StPolyfromtext withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StPolyfromtext(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStPolyfromtext(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygon.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygon.java new file mode 100644 index 0000000000..97485e31e5 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygon.java @@ -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.UnaryExpression; +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 'st_polygon'. This class is generated by GenerateScalarFunction. + */ +public class StPolygon extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StPolygon(Expression arg) { + super("st_polygon", arg); + } + + /** + * withChildren. + */ + @Override + public StPolygon withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StPolygon(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStPolygon(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygonfromtext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygonfromtext.java new file mode 100644 index 0000000000..800b4b0568 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StPolygonfromtext.java @@ -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.UnaryExpression; +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 'st_polygonfromtext'. This class is generated by GenerateScalarFunction. + */ +public class StPolygonfromtext extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StPolygonfromtext(Expression arg) { + super("st_polygonfromtext", arg); + } + + /** + * withChildren. + */ + @Override + public StPolygonfromtext withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StPolygonfromtext(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStPolygonfromtext(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StX.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StX.java new file mode 100644 index 0000000000..4a078a26a4 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StX.java @@ -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.DoubleType; +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 'st_x'. This class is generated by GenerateScalarFunction. + */ +public class StX extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(DoubleType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StX(Expression arg) { + super("st_x", arg); + } + + /** + * withChildren. + */ + @Override + public StX withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StX(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStX(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StY.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StY.java new file mode 100644 index 0000000000..050baea9f9 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StY.java @@ -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.DoubleType; +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 'st_y'. This class is generated by GenerateScalarFunction. + */ +public class StY extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(DoubleType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public StY(Expression arg) { + super("st_y", arg); + } + + /** + * withChildren. + */ + @Override + public StY withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new StY(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStY(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StartsWith.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StartsWith.java new file mode 100644 index 0000000000..513ea19cf3 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StartsWith.java @@ -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.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.BooleanType; +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 'starts_with'. This class is generated by GenerateScalarFunction. + */ +public class StartsWith extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BooleanType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public StartsWith(Expression arg0, Expression arg1) { + super("starts_with", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public StartsWith withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new StartsWith(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStartsWith(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrLeft.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrLeft.java new file mode 100644 index 0000000000..50270a940d --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrLeft.java @@ -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.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 'strleft'. This class is generated by GenerateScalarFunction. + */ +public class StrLeft extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public StrLeft(Expression arg0, Expression arg1) { + super("strleft", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public StrLeft withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new StrLeft(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStrLeft(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrRight.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrRight.java new file mode 100644 index 0000000000..4a8b9ae930 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrRight.java @@ -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.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 'strright'. This class is generated by GenerateScalarFunction. + */ +public class StrRight extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public StrRight(Expression arg0, Expression arg1) { + super("strright", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public StrRight withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new StrRight(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStrRight(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java new file mode 100644 index 0000000000..fbaf438496 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java @@ -0,0 +1,116 @@ +// 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.analysis.DateLiteral; +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.catalog.ScalarType; +import org.apache.doris.catalog.Type; +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.literal.StringLikeLiteral; +import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DataType; +import org.apache.doris.nereids.types.DateTimeType; +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 'str_to_date'. This class is generated by GenerateScalarFunction. + */ +public class StrToDate extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(DateTimeType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public StrToDate(Expression arg0, Expression arg1) { + super("str_to_date", arg0, arg1); + } + + @Override + protected FunctionSignature computeSignature(FunctionSignature signature) { + /* + * The return type of str_to_date depends on whether the time part is included in the format. + * If included, it is datetime, otherwise it is date. + * If the format parameter is not constant, the return type will be datetime. + * The above judgment has been completed in the FE query planning stage, + * so here we directly set the value type to the return type set in the query plan. + * + * For example: + * A table with one column k1 varchar, and has 2 lines: + * "%Y-%m-%d" + * "%Y-%m-%d %H:%i:%s" + * Query: + * SELECT str_to_date("2020-09-01", k1) from tbl; + * Result will be: + * 2020-09-01 00:00:00 + * 2020-09-01 00:00:00 + * + * Query: + * SELECT str_to_date("2020-09-01", "%Y-%m-%d"); + * Return type is DATE + * + * Query: + * SELECT str_to_date("2020-09-01", "%Y-%m-%d %H:%i:%s"); + * Return type is DATETIME + */ + DataType returnType; + if (child(1) instanceof StringLikeLiteral) { + if (DateLiteral.hasTimePart(((StringLikeLiteral) child(1)).getStringValue())) { + returnType = DataType.fromCatalogType(ScalarType.getDefaultDateType(Type.DATETIME)); + } else { + returnType = DataType.fromCatalogType(ScalarType.getDefaultDateType(Type.DATE)); + } + } else { + returnType = DataType.fromCatalogType(ScalarType.getDefaultDateType(Type.DATETIME)); + } + return signature.withReturnType(returnType); + } + + /** + * withChildren. + */ + @Override + public StrToDate withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new StrToDate(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStrToDate(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SubBitmap.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SubBitmap.java new file mode 100644 index 0000000000..1b2a6857aa --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SubBitmap.java @@ -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 'sub_bitmap'. This class is generated by GenerateScalarFunction. + */ +public class SubBitmap extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BitmapType.INSTANCE) + .args(BitmapType.INSTANCE, BigIntType.INSTANCE, BigIntType.INSTANCE) + ); + + /** + * constructor with 3 arguments. + */ + public SubBitmap(Expression arg0, Expression arg1, Expression arg2) { + super("sub_bitmap", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public SubBitmap withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new SubBitmap(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitSubBitmap(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Substring.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Substring.java index a3e69a9a06..a653a792c7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Substring.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Substring.java @@ -17,17 +17,17 @@ 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.literal.IntegerLiteral; import org.apache.doris.nereids.trees.expressions.literal.Literal; -import org.apache.doris.nereids.trees.expressions.typecoercion.ImplicitCastInputTypes; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DataType; import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.StringType; import org.apache.doris.nereids.types.VarcharType; -import org.apache.doris.nereids.types.coercion.AbstractDataType; -import org.apache.doris.nereids.types.coercion.TypeCollection; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -36,23 +36,43 @@ import java.util.List; import java.util.Optional; /** - * substring function. + * ScalarFunction 'substring'. This class is generated by GenerateScalarFunction. */ // TODO: to be compatible with BE, we set AlwaysNullable here. -public class Substring extends ScalarFunction implements ImplicitCastInputTypes, AlwaysNullable { - // used in interface expectedInputTypes to avoid new list in each time it be called - private static final List EXPECTED_INPUT_TYPES = ImmutableList.of( - TypeCollection.CHARACTER_TYPE_COLLECTION, - IntegerType.INSTANCE, - IntegerType.INSTANCE +public class Substring extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) + .args(VarcharType.SYSTEM_DEFAULT, IntegerType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(StringType.INSTANCE) + .args(StringType.INSTANCE, IntegerType.INSTANCE, IntegerType.INSTANCE) ); - public Substring(Expression str, Expression pos, Expression len) { - super("substring", str, pos, len); + /** + * constructor with 2 arguments. + */ + public Substring(Expression arg0, Expression arg1) { + super("substring", arg0, arg1, Literal.of(Integer.MAX_VALUE)); } - public Substring(Expression str, Expression pos) { - super("substring", str, pos, Literal.of(Integer.MAX_VALUE)); + /** + * constructor with 3 arguments. + */ + public Substring(Expression arg0, Expression arg1, Expression arg2) { + super("substring", arg0, arg1, arg2); + } + + @Override + protected FunctionSignature computeSignature(FunctionSignature signature) { + Optional length = getLength(); + DataType returnType = VarcharType.SYSTEM_DEFAULT; + if (length.isPresent() && length.get() instanceof IntegerLiteral) { + returnType = VarcharType.createVarcharType(((IntegerLiteral) length.get()).getValue()); + } + return signature.withReturnType(returnType); } public Expression getSource() { @@ -67,27 +87,23 @@ public class Substring extends ScalarFunction implements ImplicitCastInputTypes, return arity() == 3 ? Optional.of(child(2)) : Optional.empty(); } - @Override - public DataType getDataType() { - Optional length = getLength(); - if (length.isPresent() && length.get() instanceof IntegerLiteral) { - return VarcharType.createVarcharType(((IntegerLiteral) length.get()).getValue()); - } - return VarcharType.SYSTEM_DEFAULT; - } - + /** + * withChildren. + */ @Override public Substring withChildren(List children) { - Preconditions.checkArgument(children.size() == 2 || children.size() == 3); + Preconditions.checkArgument(children.size() == 2 + || children.size() == 3); if (children.size() == 2) { return new Substring(children.get(0), children.get(1)); + } else { + return new Substring(children.get(0), children.get(1), children.get(2)); } - return new Substring(children.get(0), children.get(1), children.get(2)); } @Override - public List expectedInputTypes() { - return EXPECTED_INPUT_TYPES; + public List getSignatures() { + return SIGNATURES; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Tan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Tan.java new file mode 100644 index 0000000000..793bb7c087 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Tan.java @@ -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 'tan'. This class is generated by GenerateScalarFunction. + */ +public class Tan extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Tan(Expression arg) { + super("tan", arg); + } + + /** + * withChildren. + */ + @Override + public Tan withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Tan(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitTan(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/TimeDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/TimeDiff.java new file mode 100644 index 0000000000..e6a09afb65 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/TimeDiff.java @@ -0,0 +1,78 @@ +// 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.TimeType; +import org.apache.doris.nereids.types.TimeV2Type; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'timediff'. This class is generated by GenerateScalarFunction. + */ +public class TimeDiff extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(TimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public TimeDiff(Expression arg0, Expression arg1) { + super("timediff", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public TimeDiff withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new TimeDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitTimeDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Timestamp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Timestamp.java new file mode 100644 index 0000000000..5db0114207 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Timestamp.java @@ -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.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 com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'timestamp'. This class is generated by GenerateScalarFunction. + */ +public class Timestamp extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Timestamp(Expression arg) { + super("timestamp", arg); + } + + /** + * withChildren. + */ + @Override + public Timestamp withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Timestamp(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitTimestamp(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBase64.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBase64.java new file mode 100644 index 0000000000..d1485d3506 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBase64.java @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.StringType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'to_base64'. This class is generated by GenerateScalarFunction. + */ +public class ToBase64 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public ToBase64(Expression arg) { + super("to_base64", arg); + } + + /** + * withChildren. + */ + @Override + public ToBase64 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new ToBase64(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitToBase64(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmap.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmap.java new file mode 100644 index 0000000000..7a7009c5aa --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmap.java @@ -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 'to_bitmap'. This class is generated by GenerateScalarFunction. + */ +public class ToBitmap extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BitmapType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BitmapType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public ToBitmap(Expression arg) { + super("to_bitmap", arg); + } + + /** + * withChildren. + */ + @Override + public ToBitmap withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new ToBitmap(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitToBitmap(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmapWithCheck.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmapWithCheck.java new file mode 100644 index 0000000000..ad410316a8 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToBitmapWithCheck.java @@ -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 'to_bitmap_with_check'. This class is generated by GenerateScalarFunction. + */ +public class ToBitmapWithCheck extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(BitmapType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(BitmapType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public ToBitmapWithCheck(Expression arg) { + super("to_bitmap_with_check", arg); + } + + /** + * withChildren. + */ + @Override + public ToBitmapWithCheck withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new ToBitmapWithCheck(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitToBitmapWithCheck(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDate.java new file mode 100644 index 0000000000..7b09e1d9c7 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDate.java @@ -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 'to_date'. This class is generated by GenerateScalarFunction. + */ +public class ToDate extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public ToDate(Expression arg) { + super("to_date", arg); + } + + /** + * withChildren. + */ + @Override + public ToDate withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new ToDate(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitToDate(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDateV2.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDateV2.java new file mode 100644 index 0000000000..21f9d6c813 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDateV2.java @@ -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 'to_datev2'. This class is generated by GenerateScalarFunction. + */ +public class ToDateV2 extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public ToDateV2(Expression arg) { + super("to_datev2", arg); + } + + /** + * withChildren. + */ + @Override + public ToDateV2 withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new ToDateV2(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitToDateV2(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDays.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDays.java new file mode 100644 index 0000000000..8f9da6b604 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToDays.java @@ -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.DateType; +import org.apache.doris.nereids.types.DateV2Type; +import org.apache.doris.nereids.types.IntegerType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'to_days'. This class is generated by GenerateScalarFunction. + */ +public class ToDays extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(DateType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public ToDays(Expression arg) { + super("to_days", arg); + } + + /** + * withChildren. + */ + @Override + public ToDays withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new ToDays(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitToDays(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToQuantileState.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToQuantileState.java new file mode 100644 index 0000000000..8294e5e3b4 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToQuantileState.java @@ -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.FloatType; +import org.apache.doris.nereids.types.QuantileStateType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'to_quantile_state'. This class is generated by GenerateScalarFunction. + */ +public class ToQuantileState extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(QuantileStateType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, FloatType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public ToQuantileState(Expression arg0, Expression arg1) { + super("to_quantile_state", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public ToQuantileState withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new ToQuantileState(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitToQuantileState(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Trim.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Trim.java new file mode 100644 index 0000000000..fa4cf39a2e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Trim.java @@ -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.UnaryExpression; +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 'trim'. This class is generated by GenerateScalarFunction. + */ +public class Trim extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Trim(Expression arg) { + super("trim", arg); + } + + /** + * withChildren. + */ + @Override + public Trim withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Trim(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitTrim(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java new file mode 100644 index 0000000000..9907163167 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java @@ -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.DoubleType; +import org.apache.doris.nereids.types.IntegerType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'truncate'. This class is generated by GenerateScalarFunction. + */ +public class Truncate extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 2 arguments. + */ + public Truncate(Expression arg0, Expression arg1) { + super("truncate", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Truncate withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new Truncate(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitTruncate(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Unhex.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Unhex.java new file mode 100644 index 0000000000..9e9afeb31e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Unhex.java @@ -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.UnaryExpression; +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 'unhex'. This class is generated by GenerateScalarFunction. + */ +public class Unhex extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Unhex(Expression arg) { + super("unhex", arg); + } + + /** + * withChildren. + */ + @Override + public Unhex withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Unhex(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitUnhex(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UnixTimestamp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UnixTimestamp.java new file mode 100644 index 0000000000..9ad0a26354 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UnixTimestamp.java @@ -0,0 +1,108 @@ +// 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.DateTimeType; +import org.apache.doris.nereids.types.DateTimeV2Type; +import org.apache.doris.nereids.types.DateType; +import org.apache.doris.nereids.types.DateV2Type; +import org.apache.doris.nereids.types.IntegerType; +import 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 'unix_timestamp'. This class is generated by GenerateScalarFunction. + */ +public class UnixTimestamp extends ScalarFunction + implements ExplicitlyCastableSignature { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE) + ); + + /** + * constructor with 0 argument. + */ + public UnixTimestamp() { + super("unix_timestamp"); + } + + /** + * constructor with 1 argument. + */ + public UnixTimestamp(Expression arg) { + super("unix_timestamp", arg); + } + + /** + * constructor with 2 arguments. + */ + public UnixTimestamp(Expression arg0, Expression arg1) { + super("unix_timestamp", arg0, arg1); + } + + /** + * custom compute nullable. + */ + @Override + public boolean nullable() { + return arity() > 0; + } + + /** + * withChildren. + */ + @Override + public UnixTimestamp withChildren(List children) { + Preconditions.checkArgument(children.size() == 0 + || children.size() == 1 + || children.size() == 2); + if (children.isEmpty() && arity() == 0) { + return this; + } else if (children.size() == 1) { + return new UnixTimestamp(children.get(0)); + } else { + return new UnixTimestamp(children.get(0), children.get(1)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitUnixTimestamp(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Upper.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Upper.java new file mode 100644 index 0000000000..a335abbfa5 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Upper.java @@ -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.UnaryExpression; +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 'upper'. This class is generated by GenerateScalarFunction. + */ +public class Upper extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Upper(Expression arg) { + super("upper", arg); + } + + /** + * withChildren. + */ + @Override + public Upper withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Upper(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitUpper(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UtcTimestamp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UtcTimestamp.java new file mode 100644 index 0000000000..42c1ed9665 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UtcTimestamp.java @@ -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.DateTimeType; + +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'utc_timestamp'. This class is generated by GenerateScalarFunction. + */ +public class UtcTimestamp extends ScalarFunction + implements LeafExpression, ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args() + ); + + /** + * constructor with 0 argument. + */ + public UtcTimestamp() { + super("utc_timestamp"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitUtcTimestamp(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Version.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Version.java new file mode 100644 index 0000000000..2c1e83cc0b --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Version.java @@ -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.VarcharType; + +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'version'. This class is generated by GenerateScalarFunction. + */ +public class Version extends ScalarFunction + implements LeafExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args() + ); + + /** + * constructor with 0 argument. + */ + public Version() { + super("version"); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitVersion(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java new file mode 100644 index 0000000000..b6650ba989 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java @@ -0,0 +1,87 @@ +// 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 'week'. This class is generated by GenerateScalarFunction. + */ +public class Week extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public Week(Expression arg) { + super("week", arg); + } + + /** + * constructor with 2 arguments. + */ + public Week(Expression arg0, Expression arg1) { + super("week", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public Week withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2); + if (children.size() == 1) { + return new Week(children.get(0)); + } else { + return new Week(children.get(0), children.get(1)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitWeek(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekCeil.java new file mode 100644 index 0000000000..b551e7dacb --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekCeil.java @@ -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 'week_ceil'. This class is generated by GenerateScalarFunction. + */ +public class WeekCeil extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 WeekCeil(Expression arg) { + super("week_ceil", arg); + } + + /** + * constructor with 2 arguments. + */ + public WeekCeil(Expression arg0, Expression arg1) { + super("week_ceil", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public WeekCeil(Expression arg0, Expression arg1, Expression arg2) { + super("week_ceil", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public WeekCeil withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new WeekCeil(children.get(0)); + } else if (children.size() == 2) { + return new WeekCeil(children.get(0), children.get(1)); + } else { + return new WeekCeil(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitWeekCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekFloor.java new file mode 100644 index 0000000000..e6f4398a9c --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekFloor.java @@ -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 'week_floor'. This class is generated by GenerateScalarFunction. + */ +public class WeekFloor extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 WeekFloor(Expression arg) { + super("week_floor", arg); + } + + /** + * constructor with 2 arguments. + */ + public WeekFloor(Expression arg0, Expression arg1) { + super("week_floor", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public WeekFloor(Expression arg0, Expression arg1, Expression arg2) { + super("week_floor", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public WeekFloor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new WeekFloor(children.get(0)); + } else if (children.size() == 2) { + return new WeekFloor(children.get(0), children.get(1)); + } else { + return new WeekFloor(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitWeekFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java index 77cf3b7602..965601717e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java @@ -17,16 +17,16 @@ 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.PropagateNullable; +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.typecoercion.ImplicitCastInputTypes; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; -import org.apache.doris.nereids.types.DataType; 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 org.apache.doris.nereids.types.coercion.AbstractDataType; -import org.apache.doris.nereids.types.coercion.TypeCollection; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -34,29 +34,27 @@ import com.google.common.collect.ImmutableList; import java.util.List; /** - * weekOfYear function + * ScalarFunction 'weekofyear'. This class is generated by GenerateScalarFunction. */ -public class WeekOfYear extends ScalarFunction implements UnaryExpression, ImplicitCastInputTypes, PropagateNullable { +public class WeekOfYear extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { - private static final List EXPECTED_INPUT_TYPES = ImmutableList.of( - new TypeCollection(DateTimeType.INSTANCE) + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) ); - public WeekOfYear(Expression child) { - super("weekofyear", child); - } - - @Override - public DataType getDataType() { - return IntegerType.INSTANCE; - } - - // Follow the return type of origin definition in the FunctionSet. - @Override - public boolean nullable() { - return true; + /** + * constructor with 1 argument. + */ + public WeekOfYear(Expression arg) { + super("weekofyear", arg); } + /** + * withChildren. + */ @Override public WeekOfYear withChildren(List children) { Preconditions.checkArgument(children.size() == 1); @@ -64,8 +62,8 @@ public class WeekOfYear extends ScalarFunction implements UnaryExpression, Impli } @Override - public List expectedInputTypes() { - return EXPECTED_INPUT_TYPES; + public List getSignatures() { + return SIGNATURES; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java new file mode 100644 index 0000000000..01c5d3f544 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java @@ -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 'weekday'. This class is generated by GenerateScalarFunction. + */ +public class Weekday extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 Weekday(Expression arg) { + super("weekday", arg); + } + + /** + * withChildren. + */ + @Override + public Weekday withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new Weekday(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitWeekday(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksDiff.java new file mode 100644 index 0000000000..c02488f676 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksDiff.java @@ -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 'weeks_diff'. This class is generated by GenerateScalarFunction. + */ +public class WeeksDiff extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 WeeksDiff(Expression arg0, Expression arg1) { + super("weeks_diff", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public WeeksDiff withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new WeeksDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitWeeksDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java index 4f593dfc09..688eb5516d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java @@ -17,17 +17,16 @@ 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.PropagateNullable; +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.typecoercion.ImplicitCastInputTypes; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; -import org.apache.doris.nereids.types.DataType; import org.apache.doris.nereids.types.DateTimeType; -import org.apache.doris.nereids.types.DateType; +import org.apache.doris.nereids.types.DateTimeV2Type; +import org.apache.doris.nereids.types.DateV2Type; import org.apache.doris.nereids.types.IntegerType; -import org.apache.doris.nereids.types.coercion.AbstractDataType; -import org.apache.doris.nereids.types.coercion.TypeCollection; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -35,30 +34,27 @@ import com.google.common.collect.ImmutableList; import java.util.List; /** - * year function. + * ScalarFunction 'year'. This class is generated by GenerateScalarFunction. */ -public class Year extends ScalarFunction implements UnaryExpression, ImplicitCastInputTypes, PropagateNullable { +public class Year extends ScalarFunction + implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { - // used in interface expectedInputTypes to avoid new list in each time it be called - private static final List EXPECTED_INPUT_TYPES = ImmutableList.of( - new TypeCollection(DateType.INSTANCE, DateTimeType.INSTANCE) + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) ); - public Year(Expression child) { - super("year", child); - } - - @Override - public DataType getDataType() { - return IntegerType.INSTANCE; - } - - // Follow the return type of origin definition in the FunctionSet. - @Override - public boolean nullable() { - return true; + /** + * constructor with 1 argument. + */ + public Year(Expression arg) { + super("year", arg); } + /** + * withChildren. + */ @Override public Year withChildren(List children) { Preconditions.checkArgument(children.size() == 1); @@ -66,8 +62,8 @@ public class Year extends ScalarFunction implements UnaryExpression, ImplicitCas } @Override - public List expectedInputTypes() { - return EXPECTED_INPUT_TYPES; + public List getSignatures() { + return SIGNATURES; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java new file mode 100644 index 0000000000..9d7bbb38c8 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java @@ -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 'year_ceil'. This class is generated by GenerateScalarFunction. + */ +public class YearCeil extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 YearCeil(Expression arg) { + super("year_ceil", arg); + } + + /** + * constructor with 2 arguments. + */ + public YearCeil(Expression arg0, Expression arg1) { + super("year_ceil", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public YearCeil(Expression arg0, Expression arg1, Expression arg2) { + super("year_ceil", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public YearCeil withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new YearCeil(children.get(0)); + } else if (children.size() == 2) { + return new YearCeil(children.get(0), children.get(1)); + } else { + return new YearCeil(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitYearCeil(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java new file mode 100644 index 0000000000..bb590a0865 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java @@ -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 'year_floor'. This class is generated by GenerateScalarFunction. + */ +public class YearFloor extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 YearFloor(Expression arg) { + super("year_floor", arg); + } + + /** + * constructor with 2 arguments. + */ + public YearFloor(Expression arg0, Expression arg1) { + super("year_floor", arg0, arg1); + } + + /** + * constructor with 3 arguments. + */ + public YearFloor(Expression arg0, Expression arg1, Expression arg2) { + super("year_floor", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public YearFloor withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2 + || children.size() == 3); + if (children.size() == 1) { + return new YearFloor(children.get(0)); + } else if (children.size() == 2) { + return new YearFloor(children.get(0), children.get(1)); + } else { + return new YearFloor(children.get(0), children.get(1), children.get(2)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitYearFloor(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearWeek.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearWeek.java new file mode 100644 index 0000000000..a53c46c4be --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearWeek.java @@ -0,0 +1,87 @@ +// 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 'yearweek'. This class is generated by GenerateScalarFunction. + */ +public class YearWeek extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) + ); + + /** + * constructor with 1 argument. + */ + public YearWeek(Expression arg) { + super("yearweek", arg); + } + + /** + * constructor with 2 arguments. + */ + public YearWeek(Expression arg0, Expression arg1) { + super("yearweek", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public YearWeek withChildren(List children) { + Preconditions.checkArgument(children.size() == 1 + || children.size() == 2); + if (children.size() == 1) { + return new YearWeek(children.get(0)); + } else { + return new YearWeek(children.get(0), children.get(1)); + } + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitYearWeek(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsDiff.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsDiff.java new file mode 100644 index 0000000000..916559cddf --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsDiff.java @@ -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 'years_diff'. This class is generated by GenerateScalarFunction. + */ +public class YearsDiff extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List 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 YearsDiff(Expression arg0, Expression arg1) { + super("years_diff", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public YearsDiff withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new YearsDiff(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitYearsDiff(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/BigIntLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/BigIntLiteral.java index dbe21b420b..1d703e8b0e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/BigIntLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/BigIntLiteral.java @@ -27,7 +27,7 @@ import org.apache.doris.nereids.types.BigIntType; /** * Represents Bigint literal */ -public class BigIntLiteral extends Literal { +public class BigIntLiteral extends IntegerLikeLiteral { private final long value; @@ -55,4 +55,9 @@ public class BigIntLiteral extends Literal { "Can not convert to legacy literal: " + value, e); } } + + @Override + public Number getNumber() { + return value; + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/CharLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/CharLiteral.java index be53613edf..be4c031aec 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/CharLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/CharLiteral.java @@ -22,21 +22,13 @@ import org.apache.doris.analysis.StringLiteral; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.CharType; -import com.google.common.base.Preconditions; - -import java.util.Objects; - /** * char type literal */ -public class CharLiteral extends Literal { - - private final String value; +public class CharLiteral extends StringLikeLiteral { public CharLiteral(String value, int len) { - super(CharType.createCharType(len)); - this.value = Objects.requireNonNull(value); - Preconditions.checkArgument(value.length() <= len); + super(len >= 0 ? value.substring(0, Math.min(value.length(), len)) : value, CharType.createCharType(len)); } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java index 68243b3cea..e3093c2a09 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.trees.expressions.literal; import org.apache.doris.analysis.LiteralExpr; +import org.apache.doris.catalog.ScalarType; import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DataType; @@ -58,7 +59,7 @@ public class DateLiteral extends Literal { } public DateLiteral(String s) throws AnalysisException { - super(DateType.INSTANCE); + super(DataType.fromCatalogType(ScalarType.createDateType())); init(s); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLikeLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLikeLiteral.java new file mode 100644 index 0000000000..c4e60e4c7a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLikeLiteral.java @@ -0,0 +1,38 @@ +// 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.literal; + +import org.apache.doris.nereids.types.DataType; + +/** IntegralLiteral */ +public abstract class IntegerLikeLiteral extends Literal { + /** + * Constructor for Literal. + * + * @param dataType logical data type in Nereids + */ + public IntegerLikeLiteral(DataType dataType) { + super(dataType); + } + + public int getIntValue() { + return getNumber().intValue(); + } + + public abstract Number getNumber(); +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLiteral.java index 6af432d832..9c6dd33292 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/IntegerLiteral.java @@ -27,7 +27,7 @@ import org.apache.doris.nereids.types.IntegerType; /** * Represents Integer literal */ -public class IntegerLiteral extends Literal { +public class IntegerLiteral extends IntegerLikeLiteral { private final int value; @@ -55,4 +55,9 @@ public class IntegerLiteral extends Literal { "Can not convert to legacy literal: " + value, e); } } + + @Override + public Number getNumber() { + return value; + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/LargeIntLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/LargeIntLiteral.java index ecadc0b0ab..5f9d60a2ff 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/LargeIntLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/LargeIntLiteral.java @@ -28,7 +28,7 @@ import java.util.Objects; /** * large int type literal */ -public class LargeIntLiteral extends Literal { +public class LargeIntLiteral extends IntegerLikeLiteral { private final BigInteger value; @@ -61,4 +61,9 @@ public class LargeIntLiteral extends Literal { public double getDouble() { return value.doubleValue(); } + + @Override + public Number getNumber() { + return value; + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java index 7475d93ea6..561c2c8180 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java @@ -58,21 +58,21 @@ public abstract class Literal extends Expression implements LeafExpression { if (value == null) { return new NullLiteral(); } else if (value instanceof Byte) { - return new TinyIntLiteral((byte) value); + return new TinyIntLiteral((Byte) value); } else if (value instanceof Short) { - return new SmallIntLiteral((short) value); + return new SmallIntLiteral((Short) value); } else if (value instanceof Integer) { - return new IntegerLiteral((int) value); + return new IntegerLiteral((Integer) value); } else if (value instanceof Long) { - return new BigIntLiteral((long) value); + return new BigIntLiteral((Long) value); } else if (value instanceof BigInteger) { return new LargeIntLiteral((BigInteger) value); } else if (value instanceof Float) { - return new FloatLiteral((float) value); + return new FloatLiteral((Float) value); } else if (value instanceof Double) { - return new DoubleLiteral((double) value); + return new DoubleLiteral((Double) value); } else if (value instanceof Boolean) { - return BooleanLiteral.of((boolean) value); + return BooleanLiteral.of((Boolean) value); } else if (value instanceof String) { return new StringLiteral((String) value); } else { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/SmallIntLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/SmallIntLiteral.java index 15a36971f1..e56fcf7569 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/SmallIntLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/SmallIntLiteral.java @@ -27,7 +27,7 @@ import org.apache.doris.nereids.types.SmallIntType; /** * small int type literal */ -public class SmallIntLiteral extends Literal { +public class SmallIntLiteral extends IntegerLikeLiteral { private final short value; @@ -55,4 +55,9 @@ public class SmallIntLiteral extends Literal { "Can not convert to legacy literal: " + value, e); } } + + @Override + public Number getNumber() { + return value; + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLikeLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLikeLiteral.java new file mode 100644 index 0000000000..1e4d3a4e15 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLikeLiteral.java @@ -0,0 +1,34 @@ +// 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.literal; + +import org.apache.doris.nereids.types.DataType; + +/** StringLikeLiteral. */ +public abstract class StringLikeLiteral extends Literal { + public final String value; + + public StringLikeLiteral(String value, DataType dataType) { + super(dataType); + this.value = value; + } + + public String getStringValue() { + return value; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLiteral.java index 274fbef754..c5941918fa 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLiteral.java @@ -24,7 +24,7 @@ import org.apache.doris.nereids.types.StringType; /** * Represents String literal */ -public class StringLiteral extends Literal { +public class StringLiteral extends StringLikeLiteral { private final String value; @@ -34,7 +34,7 @@ public class StringLiteral extends Literal { * @param value real value stored in java object */ public StringLiteral(String value) { - super(StringType.INSTANCE); + super(value, StringType.INSTANCE); this.value = value; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/TinyIntLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/TinyIntLiteral.java index 414255f7a6..08d46c0e5c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/TinyIntLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/TinyIntLiteral.java @@ -27,7 +27,7 @@ import org.apache.doris.nereids.types.TinyIntType; /** * tiny int type literal */ -public class TinyIntLiteral extends Literal { +public class TinyIntLiteral extends IntegerLikeLiteral { private final byte value; @@ -55,4 +55,14 @@ public class TinyIntLiteral extends Literal { "Can not convert to legacy literal: " + value, e); } } + + @Override + public int getIntValue() { + return value; + } + + @Override + public Number getNumber() { + return value; + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/VarcharLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/VarcharLiteral.java index 401a63eb6c..c4c08cb7d0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/VarcharLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/VarcharLiteral.java @@ -24,32 +24,23 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DataType; import org.apache.doris.nereids.types.VarcharType; -import com.google.common.base.Preconditions; - -import java.util.Objects; - /** * Varchar type literal, in theory, * the difference from StringLiteral is that VarcharLiteral keeps the length information. */ -public class VarcharLiteral extends Literal { - - private final String value; +public class VarcharLiteral extends StringLikeLiteral { public VarcharLiteral(String value) { - super(VarcharType.SYSTEM_DEFAULT); - this.value = Objects.requireNonNull(value); + super(value, VarcharType.SYSTEM_DEFAULT); } public VarcharLiteral(String value, int len) { - super(VarcharType.createVarcharType(len)); - this.value = Objects.requireNonNull(value); - Preconditions.checkArgument(value.length() <= len); + super(len >= 0 ? value.substring(0, Math.min(value.length(), len)) : value, VarcharType.createVarcharType(len)); } @Override public String getValue() { - return value; + return getStringValue(); } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java new file mode 100644 index 0000000000..32257be5b8 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java @@ -0,0 +1,50 @@ +// 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.visitor; + +import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction; +import org.apache.doris.nereids.trees.expressions.functions.agg.Avg; +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; + +/** AggregateFunctionVisitor. */ +public interface AggregateFunctionVisitor { + R visitAggregateFunction(AggregateFunction aggregateFunction, C context); + + default R visitAvg(Avg avg, C context) { + return visitAggregateFunction(avg, context); + } + + default R visitCount(Count count, C context) { + return visitAggregateFunction(count, context); + } + + default R visitMax(Max max, C context) { + return visitAggregateFunction(max, context); + } + + default R visitMin(Min min, C context) { + return visitAggregateFunction(min, context); + } + + default R visitSum(Sum sum, C context) { + return visitAggregateFunction(sum, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ExpressionVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ExpressionVisitor.java index 7c0b7bd322..ba6433236d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ExpressionVisitor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ExpressionVisitor.java @@ -62,14 +62,7 @@ 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.Avg; -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 org.apache.doris.nereids.trees.expressions.functions.scalar.ScalarFunction; import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral; import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral; import org.apache.doris.nereids.trees.expressions.literal.CharLiteral; @@ -90,10 +83,25 @@ import org.apache.doris.nereids.trees.expressions.literal.VarcharLiteral; /** * Use the visitor to visit expression and forward to unified method(visitExpression). */ -public abstract class ExpressionVisitor { +public abstract class ExpressionVisitor + implements ScalarFunctionVisitor, AggregateFunctionVisitor { public abstract R visit(Expression expr, C context); + @Override + public R visitAggregateFunction(AggregateFunction aggregateFunction, C context) { + return visitBoundFunction(aggregateFunction, context); + } + + @Override + public R visitScalarFunction(ScalarFunction scalarFunction, C context) { + return visitBoundFunction(scalarFunction, context); + } + + public R visitBoundFunction(BoundFunction boundFunction, C context) { + return visit(boundFunction, context); + } + public R visitAlias(Alias alias, C context) { return visitNamedExpression(alias, context); } @@ -242,10 +250,6 @@ public abstract class ExpressionVisitor { return visit(cast, context); } - public R visitBoundFunction(BoundFunction boundFunction, C context) { - return visit(boundFunction, context); - } - public R visitBinaryArithmetic(BinaryArithmetic binaryArithmetic, C context) { return visitBinaryOperator(binaryArithmetic, context); } @@ -314,34 +318,6 @@ public abstract class ExpressionVisitor { return visit(assertNumRowsElement, context); } - /* ******************************************************************************************** - * Aggregate functions - * ********************************************************************************************/ - - public R visitAggregateFunction(AggregateFunction aggregateFunction, C context) { - return visitBoundFunction(aggregateFunction, context); - } - - public R visitAvg(Avg avg, C context) { - return visitAggregateFunction(avg, context); - } - - public R visitCount(Count count, C context) { - return visitAggregateFunction(count, context); - } - - public R visitMax(Max max, C context) { - return visitAggregateFunction(max, context); - } - - public R visitMin(Min min, C context) { - return visitAggregateFunction(min, context); - } - - public R visitSum(Sum sum, C context) { - return visitAggregateFunction(sum, context); - } - /* ******************************************************************************************** * Unbound expressions * ********************************************************************************************/ @@ -361,16 +337,4 @@ public abstract class ExpressionVisitor { public R visitUnboundStar(UnboundStar unboundStar, C context) { return visitNamedExpression(unboundStar, context); } - - public R visitYear(Year year, C context) { - return visitBoundFunction(year, context); - } - - public R visitWeekOfYear(WeekOfYear weekOfYear, C context) { - return visitBoundFunction(weekOfYear, context); - } - - public R visitSubstring(Substring substring, C context) { - return visitBoundFunction(substring, context); - } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java new file mode 100644 index 0000000000..00ddc6556a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java @@ -0,0 +1,1206 @@ +// 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.visitor; + +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.ScalarFunction; +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; + +/** ScalarFunctionVisitor. */ +public interface ScalarFunctionVisitor { + + R visitScalarFunction(ScalarFunction scalarFunction, C context); + + default R visitAbs(Abs abs, C context) { + return visitScalarFunction(abs, context); + } + + default R visitAcos(Acos acos, C context) { + return visitScalarFunction(acos, context); + } + + default R visitAesDecrypt(AesDecrypt aesDecrypt, C context) { + return visitScalarFunction(aesDecrypt, context); + } + + default R visitAesEncrypt(AesEncrypt aesEncrypt, C context) { + return visitScalarFunction(aesEncrypt, context); + } + + default R visitAppendTrailingCharIfAbsent(AppendTrailingCharIfAbsent function, C context) { + return visitScalarFunction(function, context); + } + + default R visitAscii(Ascii ascii, C context) { + return visitScalarFunction(ascii, context); + } + + default R visitAsin(Asin asin, C context) { + return visitScalarFunction(asin, context); + } + + default R visitAtan(Atan atan, C context) { + return visitScalarFunction(atan, context); + } + + default R visitBin(Bin bin, C context) { + return visitScalarFunction(bin, context); + } + + default R visitBitLength(BitLength bitLength, C context) { + return visitScalarFunction(bitLength, context); + } + + default R visitBitmapAnd(BitmapAnd bitmapAnd, C context) { + return visitScalarFunction(bitmapAnd, context); + } + + default R visitBitmapAndCount(BitmapAndCount bitmapAndCount, C context) { + return visitScalarFunction(bitmapAndCount, context); + } + + default R visitBitmapAndNot(BitmapAndNot bitmapAndNot, C context) { + return visitScalarFunction(bitmapAndNot, context); + } + + default R visitBitmapAndNotCount(BitmapAndNotCount bitmapAndNotCount, C context) { + return visitScalarFunction(bitmapAndNotCount, context); + } + + default R visitBitmapContains(BitmapContains bitmapContains, C context) { + return visitScalarFunction(bitmapContains, context); + } + + default R visitBitmapCount(BitmapCount bitmapCount, C context) { + return visitScalarFunction(bitmapCount, context); + } + + default R visitBitmapEmpty(BitmapEmpty bitmapEmpty, C context) { + return visitScalarFunction(bitmapEmpty, context); + } + + default R visitBitmapFromString(BitmapFromString bitmapFromString, C context) { + return visitScalarFunction(bitmapFromString, context); + } + + default R visitBitmapHasAll(BitmapHasAll bitmapHasAll, C context) { + return visitScalarFunction(bitmapHasAll, context); + } + + default R visitBitmapHasAny(BitmapHasAny bitmapHasAny, C context) { + return visitScalarFunction(bitmapHasAny, context); + } + + default R visitBitmapHash(BitmapHash bitmapHash, C context) { + return visitScalarFunction(bitmapHash, context); + } + + default R visitBitmapHash64(BitmapHash64 bitmapHash64, C context) { + return visitScalarFunction(bitmapHash64, context); + } + + default R visitBitmapMax(BitmapMax bitmapMax, C context) { + return visitScalarFunction(bitmapMax, context); + } + + default R visitBitmapMin(BitmapMin bitmapMin, C context) { + return visitScalarFunction(bitmapMin, context); + } + + default R visitBitmapNot(BitmapNot bitmapNot, C context) { + return visitScalarFunction(bitmapNot, context); + } + + default R visitBitmapOr(BitmapOr bitmapOr, C context) { + return visitScalarFunction(bitmapOr, context); + } + + default R visitBitmapOrCount(BitmapOrCount bitmapOrCount, C context) { + return visitScalarFunction(bitmapOrCount, context); + } + + default R visitBitmapSubsetInRange(BitmapSubsetInRange bitmapSubsetInRange, C context) { + return visitScalarFunction(bitmapSubsetInRange, context); + } + + default R visitBitmapSubsetLimit(BitmapSubsetLimit bitmapSubsetLimit, C context) { + return visitScalarFunction(bitmapSubsetLimit, context); + } + + default R visitBitmapToString(BitmapToString bitmapToString, C context) { + return visitScalarFunction(bitmapToString, context); + } + + default R visitBitmapXor(BitmapXor bitmapXor, C context) { + return visitScalarFunction(bitmapXor, context); + } + + default R visitBitmapXorCount(BitmapXorCount bitmapXorCount, C context) { + return visitScalarFunction(bitmapXorCount, context); + } + + default R visitCbrt(Cbrt cbrt, C context) { + return visitScalarFunction(cbrt, context); + } + + default R visitCeil(Ceil ceil, C context) { + return visitScalarFunction(ceil, context); + } + + default R visitCeiling(Ceiling ceiling, C context) { + return visitScalarFunction(ceiling, context); + } + + default R visitCharLength(CharLength charLength, C context) { + return visitScalarFunction(charLength, context); + } + + default R visitCharacterLength(CharacterLength characterLength, C context) { + return visitScalarFunction(characterLength, context); + } + + default R visitCoalesce(Coalesce coalesce, C context) { + return visitScalarFunction(coalesce, context); + } + + default R visitConcat(Concat concat, C context) { + return visitScalarFunction(concat, context); + } + + default R visitConcatWs(ConcatWs concatWs, C context) { + return visitScalarFunction(concatWs, context); + } + + default R visitConv(Conv conv, C context) { + return visitScalarFunction(conv, context); + } + + default R visitConvertTz(ConvertTz convertTz, C context) { + return visitScalarFunction(convertTz, context); + } + + default R visitCos(Cos cos, C context) { + return visitScalarFunction(cos, context); + } + + default R visitCurrentDate(CurrentDate currentDate, C context) { + return visitScalarFunction(currentDate, context); + } + + default R visitCurrentTime(CurrentTime currentTime, C context) { + return visitScalarFunction(currentTime, context); + } + + default R visitCurrentTimestamp(CurrentTimestamp currentTimestamp, C context) { + return visitScalarFunction(currentTimestamp, context); + } + + default R visitCurtime(Curtime curtime, C context) { + return visitScalarFunction(curtime, context); + } + + default R visitDate(Date date, C context) { + return visitScalarFunction(date, context); + } + + default R visitDateDiff(DateDiff dateDiff, C context) { + return visitScalarFunction(dateDiff, context); + } + + default R visitDateFormat(DateFormat dateFormat, C context) { + return visitScalarFunction(dateFormat, context); + } + + default R visitDateTrunc(DateTrunc dateTrunc, C context) { + return visitScalarFunction(dateTrunc, context); + } + + default R visitDateV2(DateV2 dateV2, C context) { + return visitScalarFunction(dateV2, context); + } + + default R visitDay(Day day, C context) { + return visitScalarFunction(day, context); + } + + default R visitDayCeil(DayCeil dayCeil, C context) { + return visitScalarFunction(dayCeil, context); + } + + default R visitDayFloor(DayFloor dayFloor, C context) { + return visitScalarFunction(dayFloor, context); + } + + default R visitDayName(DayName dayName, C context) { + return visitScalarFunction(dayName, context); + } + + default R visitDayOfMonth(DayOfMonth dayOfMonth, C context) { + return visitScalarFunction(dayOfMonth, context); + } + + default R visitDayOfWeek(DayOfWeek dayOfWeek, C context) { + return visitScalarFunction(dayOfWeek, context); + } + + default R visitDayOfYear(DayOfYear dayOfYear, C context) { + return visitScalarFunction(dayOfYear, context); + } + + default R visitDaysDiff(DaysDiff daysDiff, C context) { + return visitScalarFunction(daysDiff, context); + } + + default R visitDceil(Dceil dceil, C context) { + return visitScalarFunction(dceil, context); + } + + default R visitDegrees(Degrees degrees, C context) { + return visitScalarFunction(degrees, context); + } + + default R visitDexp(Dexp dexp, C context) { + return visitScalarFunction(dexp, context); + } + + default R visitDfloor(Dfloor dfloor, C context) { + return visitScalarFunction(dfloor, context); + } + + default R visitDlog1(Dlog1 dlog1, C context) { + return visitScalarFunction(dlog1, context); + } + + default R visitDlog10(Dlog10 dlog10, C context) { + return visitScalarFunction(dlog10, context); + } + + default R visitDpow(Dpow dpow, C context) { + return visitScalarFunction(dpow, context); + } + + default R visitDround(Dround dround, C context) { + return visitScalarFunction(dround, context); + } + + default R visitDsqrt(Dsqrt dsqrt, C context) { + return visitScalarFunction(dsqrt, context); + } + + default R visitE(E e, C context) { + return visitScalarFunction(e, context); + } + + default R visitElt(Elt elt, C context) { + return visitScalarFunction(elt, context); + } + + default R visitEndsWith(EndsWith endsWith, C context) { + return visitScalarFunction(endsWith, context); + } + + default R visitEsQuery(EsQuery esQuery, C context) { + return visitScalarFunction(esQuery, context); + } + + default R visitExp(Exp exp, C context) { + return visitScalarFunction(exp, context); + } + + default R visitExtractUrlParameter(ExtractUrlParameter extractUrlParameter, C context) { + return visitScalarFunction(extractUrlParameter, context); + } + + default R visitFindInSet(FindInSet findInSet, C context) { + return visitScalarFunction(findInSet, context); + } + + default R visitFloor(Floor floor, C context) { + return visitScalarFunction(floor, context); + } + + default R visitFmod(Fmod fmod, C context) { + return visitScalarFunction(fmod, context); + } + + default R visitFpow(Fpow fpow, C context) { + return visitScalarFunction(fpow, context); + } + + default R visitFromBase64(FromBase64 fromBase64, C context) { + return visitScalarFunction(fromBase64, context); + } + + default R visitFromDays(FromDays fromDays, C context) { + return visitScalarFunction(fromDays, context); + } + + default R visitFromUnixtime(FromUnixtime fromUnixtime, C context) { + return visitScalarFunction(fromUnixtime, context); + } + + default R visitGetJsonDouble(GetJsonDouble getJsonDouble, C context) { + return visitScalarFunction(getJsonDouble, context); + } + + default R visitGetJsonInt(GetJsonInt getJsonInt, C context) { + return visitScalarFunction(getJsonInt, context); + } + + default R visitGetJsonString(GetJsonString getJsonString, C context) { + return visitScalarFunction(getJsonString, context); + } + + default R visitGreatest(Greatest greatest, C context) { + return visitScalarFunction(greatest, context); + } + + default R visitHex(Hex hex, C context) { + return visitScalarFunction(hex, context); + } + + default R visitHllCardinality(HllCardinality hllCardinality, C context) { + return visitScalarFunction(hllCardinality, context); + } + + default R visitHllEmpty(HllEmpty hllEmpty, C context) { + return visitScalarFunction(hllEmpty, context); + } + + default R visitHllHash(HllHash hllHash, C context) { + return visitScalarFunction(hllHash, context); + } + + default R visitHour(Hour hour, C context) { + return visitScalarFunction(hour, context); + } + + default R visitHourCeil(HourCeil hourCeil, C context) { + return visitScalarFunction(hourCeil, context); + } + + default R visitHourFloor(HourFloor hourFloor, C context) { + return visitScalarFunction(hourFloor, context); + } + + default R visitHoursDiff(HoursDiff hoursDiff, C context) { + return visitScalarFunction(hoursDiff, context); + } + + default R visitIf(If function, C context) { + return visitScalarFunction(function, context); + } + + default R visitInitcap(Initcap initcap, C context) { + return visitScalarFunction(initcap, context); + } + + default R visitInstr(Instr instr, C context) { + return visitScalarFunction(instr, context); + } + + default R visitJsonArray(JsonArray jsonArray, C context) { + return visitScalarFunction(jsonArray, context); + } + + default R visitJsonObject(JsonObject jsonObject, C context) { + return visitScalarFunction(jsonObject, context); + } + + default R visitJsonQuote(JsonQuote jsonQuote, C context) { + return visitScalarFunction(jsonQuote, context); + } + + default R visitJsonbExistsPath(JsonbExistsPath jsonbExistsPath, C context) { + return visitScalarFunction(jsonbExistsPath, context); + } + + default R visitJsonbExtract(JsonbExtract jsonbExtract, C context) { + return visitScalarFunction(jsonbExtract, context); + } + + default R visitJsonbExtractBigint(JsonbExtractBigint jsonbExtractBigint, C context) { + return visitScalarFunction(jsonbExtractBigint, context); + } + + default R visitJsonbExtractBool(JsonbExtractBool jsonbExtractBool, C context) { + return visitScalarFunction(jsonbExtractBool, context); + } + + default R visitJsonbExtractDouble(JsonbExtractDouble jsonbExtractDouble, C context) { + return visitScalarFunction(jsonbExtractDouble, context); + } + + default R visitJsonbExtractInt(JsonbExtractInt jsonbExtractInt, C context) { + return visitScalarFunction(jsonbExtractInt, context); + } + + default R visitJsonbExtractIsnull(JsonbExtractIsnull jsonbExtractIsnull, C context) { + return visitScalarFunction(jsonbExtractIsnull, context); + } + + default R visitJsonbExtractString(JsonbExtractString jsonbExtractString, C context) { + return visitScalarFunction(jsonbExtractString, context); + } + + default R visitJsonbParse(JsonbParse jsonbParse, C context) { + return visitScalarFunction(jsonbParse, context); + } + + default R visitJsonbParseErrorToInvalid(JsonbParseErrorToInvalid function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbParseErrorToNull(JsonbParseErrorToNull function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbParseErrorToValue(JsonbParseErrorToValue function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbParseNotnull(JsonbParseNotnull jsonbParseNotnull, C context) { + return visitScalarFunction(jsonbParseNotnull, context); + } + + default R visitJsonbParseNotnullErrorToInvalid(JsonbParseNotnullErrorToInvalid function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbParseNotnullErrorToValue(JsonbParseNotnullErrorToValue function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbParseNullable(JsonbParseNullable jsonbParseNullable, C context) { + return visitScalarFunction(jsonbParseNullable, context); + } + + default R visitJsonbParseNullableErrorToInvalid(JsonbParseNullableErrorToInvalid function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbParseNullableErrorToNull(JsonbParseNullableErrorToNull function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbParseNullableErrorToValue(JsonbParseNullableErrorToValue function, C context) { + return visitScalarFunction(function, context); + } + + default R visitJsonbType(JsonbType jsonbType, C context) { + return visitScalarFunction(jsonbType, context); + } + + default R visitLeast(Least least, C context) { + return visitScalarFunction(least, context); + } + + default R visitLeft(Left left, C context) { + return visitScalarFunction(left, context); + } + + default R visitLength(Length length, C context) { + return visitScalarFunction(length, context); + } + + default R visitLn(Ln ln, C context) { + return visitScalarFunction(ln, context); + } + + default R visitLocalTime(LocalTime localTime, C context) { + return visitScalarFunction(localTime, context); + } + + default R visitLocalTimestamp(LocalTimestamp localTimestamp, C context) { + return visitScalarFunction(localTimestamp, context); + } + + default R visitLocate(Locate locate, C context) { + return visitScalarFunction(locate, context); + } + + default R visitLog(Log log, C context) { + return visitScalarFunction(log, context); + } + + default R visitLog10(Log10 log10, C context) { + return visitScalarFunction(log10, context); + } + + default R visitLog2(Log2 log2, C context) { + return visitScalarFunction(log2, context); + } + + default R visitLower(Lower lower, C context) { + return visitScalarFunction(lower, context); + } + + default R visitLpad(Lpad lpad, C context) { + return visitScalarFunction(lpad, context); + } + + default R visitLtrim(Ltrim ltrim, C context) { + return visitScalarFunction(ltrim, context); + } + + default R visitMakeDate(MakeDate makeDate, C context) { + return visitScalarFunction(makeDate, context); + } + + default R visitMd5(Md5 md5, C context) { + return visitScalarFunction(md5, context); + } + + default R visitMd5Sum(Md5Sum md5Sum, C context) { + return visitScalarFunction(md5Sum, context); + } + + default R visitMinute(Minute minute, C context) { + return visitScalarFunction(minute, context); + } + + default R visitMinuteCeil(MinuteCeil minuteCeil, C context) { + return visitScalarFunction(minuteCeil, context); + } + + default R visitMinuteFloor(MinuteFloor minuteFloor, C context) { + return visitScalarFunction(minuteFloor, context); + } + + default R visitMinutesDiff(MinutesDiff minutesDiff, C context) { + return visitScalarFunction(minutesDiff, context); + } + + default R visitMoneyFormat(MoneyFormat moneyFormat, C context) { + return visitScalarFunction(moneyFormat, context); + } + + default R visitMonth(Month month, C context) { + return visitScalarFunction(month, context); + } + + default R visitMonthCeil(MonthCeil monthCeil, C context) { + return visitScalarFunction(monthCeil, context); + } + + default R visitMonthFloor(MonthFloor monthFloor, C context) { + return visitScalarFunction(monthFloor, context); + } + + default R visitMonthName(MonthName monthName, C context) { + return visitScalarFunction(monthName, context); + } + + default R visitMonthsDiff(MonthsDiff monthsDiff, C context) { + return visitScalarFunction(monthsDiff, context); + } + + default R visitMurmurHash332(MurmurHash332 murmurHash332, C context) { + return visitScalarFunction(murmurHash332, context); + } + + default R visitMurmurHash364(MurmurHash364 murmurHash364, C context) { + return visitScalarFunction(murmurHash364, context); + } + + default R visitNegative(Negative negative, C context) { + return visitScalarFunction(negative, context); + } + + default R visitNotNullOrEmpty(NotNullOrEmpty notNullOrEmpty, C context) { + return visitScalarFunction(notNullOrEmpty, context); + } + + default R visitNow(Now now, C context) { + return visitScalarFunction(now, context); + } + + default R visitNullIf(NullIf nullIf, C context) { + return visitScalarFunction(nullIf, context); + } + + default R visitNullOrEmpty(NullOrEmpty nullOrEmpty, C context) { + return visitScalarFunction(nullOrEmpty, context); + } + + default R visitNvl(Nvl nvl, C context) { + return visitScalarFunction(nvl, context); + } + + default R visitParseUrl(ParseUrl parseUrl, C context) { + return visitScalarFunction(parseUrl, context); + } + + default R visitPi(Pi pi, C context) { + return visitScalarFunction(pi, context); + } + + default R visitPmod(Pmod pmod, C context) { + return visitScalarFunction(pmod, context); + } + + default R visitPositive(Positive positive, C context) { + return visitScalarFunction(positive, context); + } + + default R visitPow(Pow pow, C context) { + return visitScalarFunction(pow, context); + } + + default R visitPower(Power power, C context) { + return visitScalarFunction(power, context); + } + + default R visitQuantilePercent(QuantilePercent quantilePercent, C context) { + return visitScalarFunction(quantilePercent, context); + } + + default R visitQuarter(Quarter quarter, C context) { + return visitScalarFunction(quarter, context); + } + + default R visitRadians(Radians radians, C context) { + return visitScalarFunction(radians, context); + } + + default R visitRandom(Random random, C context) { + return visitScalarFunction(random, context); + } + + default R visitRegexpExtract(RegexpExtract regexpExtract, C context) { + return visitScalarFunction(regexpExtract, context); + } + + default R visitRegexpReplace(RegexpReplace regexpReplace, C context) { + return visitScalarFunction(regexpReplace, context); + } + + default R visitRepeat(Repeat repeat, C context) { + return visitScalarFunction(repeat, context); + } + + default R visitReplace(Replace replace, C context) { + return visitScalarFunction(replace, context); + } + + default R visitReverse(Reverse reverse, C context) { + return visitScalarFunction(reverse, context); + } + + default R visitRight(Right right, C context) { + return visitScalarFunction(right, context); + } + + default R visitRound(Round round, C context) { + return visitScalarFunction(round, context); + } + + default R visitRpad(Rpad rpad, C context) { + return visitScalarFunction(rpad, context); + } + + default R visitRtrim(Rtrim rtrim, C context) { + return visitScalarFunction(rtrim, context); + } + + default R visitSecond(Second second, C context) { + return visitScalarFunction(second, context); + } + + default R visitSecondCeil(SecondCeil secondCeil, C context) { + return visitScalarFunction(secondCeil, context); + } + + default R visitSecondFloor(SecondFloor secondFloor, C context) { + return visitScalarFunction(secondFloor, context); + } + + default R visitSecondsDiff(SecondsDiff secondsDiff, C context) { + return visitScalarFunction(secondsDiff, context); + } + + default R visitSign(Sign sign, C context) { + return visitScalarFunction(sign, context); + } + + default R visitSin(Sin sin, C context) { + return visitScalarFunction(sin, context); + } + + default R visitSleep(Sleep sleep, C context) { + return visitScalarFunction(sleep, context); + } + + default R visitSm3(Sm3 sm3, C context) { + return visitScalarFunction(sm3, context); + } + + default R visitSm3sum(Sm3sum sm3sum, C context) { + return visitScalarFunction(sm3sum, context); + } + + default R visitSm4Decrypt(Sm4Decrypt sm4Decrypt, C context) { + return visitScalarFunction(sm4Decrypt, context); + } + + default R visitSm4Encrypt(Sm4Encrypt sm4Encrypt, C context) { + return visitScalarFunction(sm4Encrypt, context); + } + + default R visitSpace(Space space, C context) { + return visitScalarFunction(space, context); + } + + default R visitSplitPart(SplitPart splitPart, C context) { + return visitScalarFunction(splitPart, context); + } + + default R visitSqrt(Sqrt sqrt, C context) { + return visitScalarFunction(sqrt, context); + } + + default R visitStAstext(StAstext stAstext, C context) { + return visitScalarFunction(stAstext, context); + } + + default R visitStAswkt(StAswkt stAswkt, C context) { + return visitScalarFunction(stAswkt, context); + } + + default R visitStCircle(StCircle stCircle, C context) { + return visitScalarFunction(stCircle, context); + } + + default R visitStContains(StContains stContains, C context) { + return visitScalarFunction(stContains, context); + } + + default R visitStDistanceSphere(StDistanceSphere stDistanceSphere, C context) { + return visitScalarFunction(stDistanceSphere, context); + } + + default R visitStGeometryfromtext(StGeometryfromtext stGeometryfromtext, C context) { + return visitScalarFunction(stGeometryfromtext, context); + } + + default R visitStGeomfromtext(StGeomfromtext stGeomfromtext, C context) { + return visitScalarFunction(stGeomfromtext, context); + } + + default R visitStLinefromtext(StLinefromtext stLinefromtext, C context) { + return visitScalarFunction(stLinefromtext, context); + } + + default R visitStLinestringfromtext(StLinestringfromtext stLinestringfromtext, C context) { + return visitScalarFunction(stLinestringfromtext, context); + } + + default R visitStPoint(StPoint stPoint, C context) { + return visitScalarFunction(stPoint, context); + } + + default R visitStPolyfromtext(StPolyfromtext stPolyfromtext, C context) { + return visitScalarFunction(stPolyfromtext, context); + } + + default R visitStPolygon(StPolygon stPolygon, C context) { + return visitScalarFunction(stPolygon, context); + } + + default R visitStPolygonfromtext(StPolygonfromtext stPolygonfromtext, C context) { + return visitScalarFunction(stPolygonfromtext, context); + } + + default R visitStX(StX stX, C context) { + return visitScalarFunction(stX, context); + } + + default R visitStY(StY stY, C context) { + return visitScalarFunction(stY, context); + } + + default R visitStartsWith(StartsWith startsWith, C context) { + return visitScalarFunction(startsWith, context); + } + + default R visitStrLeft(StrLeft strLeft, C context) { + return visitScalarFunction(strLeft, context); + } + + default R visitStrRight(StrRight strRight, C context) { + return visitScalarFunction(strRight, context); + } + + default R visitStrToDate(StrToDate strToDate, C context) { + return visitScalarFunction(strToDate, context); + } + + default R visitSubBitmap(SubBitmap subBitmap, C context) { + return visitScalarFunction(subBitmap, context); + } + + default R visitSubstring(Substring substring, C context) { + return visitScalarFunction(substring, context); + } + + default R visitTan(Tan tan, C context) { + return visitScalarFunction(tan, context); + } + + default R visitTimeDiff(TimeDiff timeDiff, C context) { + return visitScalarFunction(timeDiff, context); + } + + default R visitTimestamp(Timestamp timestamp, C context) { + return visitScalarFunction(timestamp, context); + } + + default R visitToBase64(ToBase64 toBase64, C context) { + return visitScalarFunction(toBase64, context); + } + + default R visitToBitmap(ToBitmap toBitmap, C context) { + return visitScalarFunction(toBitmap, context); + } + + default R visitToBitmapWithCheck(ToBitmapWithCheck toBitmapWithCheck, C context) { + return visitScalarFunction(toBitmapWithCheck, context); + } + + default R visitToDate(ToDate toDate, C context) { + return visitScalarFunction(toDate, context); + } + + default R visitToDateV2(ToDateV2 toDateV2, C context) { + return visitScalarFunction(toDateV2, context); + } + + default R visitToDays(ToDays toDays, C context) { + return visitScalarFunction(toDays, context); + } + + default R visitToQuantileState(ToQuantileState toQuantileState, C context) { + return visitScalarFunction(toQuantileState, context); + } + + default R visitTrim(Trim trim, C context) { + return visitScalarFunction(trim, context); + } + + default R visitTruncate(Truncate truncate, C context) { + return visitScalarFunction(truncate, context); + } + + default R visitUnhex(Unhex unhex, C context) { + return visitScalarFunction(unhex, context); + } + + default R visitUnixTimestamp(UnixTimestamp unixTimestamp, C context) { + return visitScalarFunction(unixTimestamp, context); + } + + default R visitUpper(Upper upper, C context) { + return visitScalarFunction(upper, context); + } + + default R visitUtcTimestamp(UtcTimestamp utcTimestamp, C context) { + return visitScalarFunction(utcTimestamp, context); + } + + default R visitVersion(Version version, C context) { + return visitScalarFunction(version, context); + } + + default R visitWeek(Week week, C context) { + return visitScalarFunction(week, context); + } + + default R visitWeekCeil(WeekCeil weekCeil, C context) { + return visitScalarFunction(weekCeil, context); + } + + default R visitWeekFloor(WeekFloor weekFloor, C context) { + return visitScalarFunction(weekFloor, context); + } + + default R visitWeekOfYear(WeekOfYear weekOfYear, C context) { + return visitScalarFunction(weekOfYear, context); + } + + default R visitWeekday(Weekday weekday, C context) { + return visitScalarFunction(weekday, context); + } + + default R visitWeeksDiff(WeeksDiff weeksDiff, C context) { + return visitScalarFunction(weeksDiff, context); + } + + default R visitYear(Year year, C context) { + return visitScalarFunction(year, context); + } + + default R visitYearCeil(YearCeil yearCeil, C context) { + return visitScalarFunction(yearCeil, context); + } + + default R visitYearFloor(YearFloor yearFloor, C context) { + return visitScalarFunction(yearFloor, context); + } + + default R visitYearWeek(YearWeek yearWeek, C context) { + return visitScalarFunction(yearWeek, context); + } + + default R visitYearsDiff(YearsDiff yearsDiff, C context) { + return visitScalarFunction(yearsDiff, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java index 4721289b97..6f15f3549b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java @@ -76,7 +76,8 @@ public class LogicalAggregate extends LogicalUnary groupByExpressions, List outputExpressions, CHILD_TYPE child) { - this(groupByExpressions, outputExpressions, Optional.empty(), false, false, true, AggPhase.LOCAL, child); + this(groupByExpressions, outputExpressions, Optional.empty(), false, + false, true, AggPhase.LOCAL, child); } public LogicalAggregate( @@ -87,8 +88,8 @@ public class LogicalAggregate extends LogicalUnary, Supplier> PROMOTION_MAP @@ -109,17 +121,36 @@ public abstract class DataType implements AbstractDataType { return StringType.INSTANCE; case DATE: return DateType.INSTANCE; + case DATEV2: + return DateV2Type.INSTANCE; case DATETIME: return DateTimeType.INSTANCE; + case DATETIMEV2: + return DateTimeV2Type.of(scalarType.getScalarScale()); case DECIMALV2: return DecimalType.createDecimalType(scalarType.decimalPrecision(), scalarType.decimalScale()); + case DECIMAL32: + case DECIMAL64: + case DECIMAL128: + return DecimalV3Type.createDecimalV3Type(scalarType.getScalarPrecision()); + case JSONB: + return JsonType.INSTANCE; + case HLL: + return HllType.INSTANCE; + case BITMAP: + return BitmapType.INSTANCE; + case QUANTILE_STATE: + return QuantileStateType.INSTANCE; case NULL_TYPE: return NullType.INSTANCE; default: throw new AnalysisException("Nereids do not support type: " + scalarType.getPrimitiveType()); } } else if (catalogType.isArrayType()) { - throw new AnalysisException("Nereids do not support array type."); + org.apache.doris.catalog.ArrayType catalogArrayType = (org.apache.doris.catalog.ArrayType) catalogType; + return ArrayType.of( + convertFromCatalogDataType(catalogArrayType.getItemType()), + catalogArrayType.getContainsNull()); } else if (catalogType.isMapType()) { throw new AnalysisException("Nereids do not support map type."); } else if (catalogType.isStructType()) { @@ -141,7 +172,7 @@ public abstract class DataType implements AbstractDataType { public static DataType convertFromString(String type) { // TODO: use a better way to resolve types // TODO: support varchar, char, decimal - type = type.toLowerCase(); + type = type.toLowerCase().trim(); switch (type) { case "bool": case "boolean": @@ -166,11 +197,7 @@ public abstract class DataType implements AbstractDataType { case "double": return DoubleType.INSTANCE; case "decimal": - return DecimalType.SYSTEM_DEFAULT; - case "char": - return CharType.INSTANCE; - case "varchar": - return VarcharType.SYSTEM_DEFAULT; + return fromCatalogType(ScalarType.createDecimalType()); case "text": case "string": return StringType.INSTANCE; @@ -178,10 +205,9 @@ public abstract class DataType implements AbstractDataType { case "null_type": // ScalarType.NULL.toSql() return "null_type", so support it return NullType.INSTANCE; case "date": - return DateType.INSTANCE; - case "datetime": - case "datetime(0)": - return DateTimeType.INSTANCE; + return fromCatalogType(ScalarType.createDateType()); + case "datev2": + return DateV2Type.INSTANCE; case "time": return TimeType.INSTANCE; case "hll": @@ -190,10 +216,27 @@ public abstract class DataType implements AbstractDataType { return BitmapType.INSTANCE; case "quantile_state": return QuantileStateType.INSTANCE; + case "json": + return JsonType.INSTANCE; default: - Optional varcharType = matchVarchar(type); - if (varcharType.isPresent()) { - return varcharType.get(); + Optional newType = matchVarchar(type); + if (newType.isPresent()) { + return newType.get(); + } + + newType = matchChar(type); + if (newType.isPresent()) { + return newType.get(); + } + + newType = matchDateTime(type); + if (newType.isPresent()) { + return newType.get(); + } + + newType = matchDecimalType(type); + if (newType.isPresent()) { + return newType.get(); } if (type.startsWith("array")) { return resolveArrayType(type); @@ -207,8 +250,9 @@ public abstract class DataType implements AbstractDataType { * @param type legacy date type * @return nereids's data type */ - public static DataType fromLegacyType(Type type) { - if (type == Type.BOOLEAN) { + @Developing // should support decimal_v3 + public static DataType fromCatalogType(Type type) { + if (type.isBoolean()) { return BooleanType.INSTANCE; } else if (type == Type.TINYINT) { return TinyIntType.INSTANCE; @@ -226,40 +270,52 @@ public abstract class DataType implements AbstractDataType { return DoubleType.INSTANCE; } else if (type == Type.STRING) { return StringType.INSTANCE; - } else if (type == Type.NULL) { + } else if (type.isNull()) { return NullType.INSTANCE; - } else if (type == Type.DATE) { - return DateType.INSTANCE; - } else if (type == Type.DATEV2) { - return DateV2Type.INSTANCE; - } else if (type == Type.DATETIME) { + } else if (type.isDatetimeV2()) { + return DateTimeV2Type.of(((ScalarType) type).getScalarScale()); + } else if (type.isDatetime()) { return DateTimeType.INSTANCE; - } else if (type == Type.DATETIMEV2) { - return DateTimeV2Type.INSTANCE; - } else if (type == Type.TIME) { - return TimeType.INSTANCE; - } else if (type == Type.TIMEV2) { + } else if (type.isDateV2()) { + return DateV2Type.INSTANCE; + } else if (type.isDateType()) { + return DateType.INSTANCE; + } else if (type.isTimeV2()) { return TimeV2Type.INSTANCE; - } else if (type == Type.HLL) { + } else if (type.isTime()) { + return TimeType.INSTANCE; + } else if (type.isHllType()) { return HllType.INSTANCE; - } else if (type == Type.BITMAP) { + } else if (type.isBitmapType()) { return BitmapType.INSTANCE; - } else if (type == Type.QUANTILE_STATE) { + } else if (type.isQuantileStateType()) { return QuantileStateType.INSTANCE; } else if (type.getPrimitiveType() == org.apache.doris.catalog.PrimitiveType.CHAR) { return CharType.createCharType(type.getLength()); } else if (type.getPrimitiveType() == org.apache.doris.catalog.PrimitiveType.VARCHAR) { return VarcharType.createVarcharType(type.getLength()); - } else if (type == Type.DECIMALV2) { - return DecimalType.SYSTEM_DEFAULT; + } else if (type.isDecimalV3()) { + ScalarType scalarType = (ScalarType) type; + int precision = scalarType.getScalarPrecision(); + return DecimalV3Type.createDecimalV3Type(precision); + } else if (type.isDecimalV2()) { + ScalarType scalarType = (ScalarType) type; + int precision = scalarType.getScalarPrecision(); + int scale = scalarType.getScalarScale(); + return DecimalV2Type.createDecimalV2Type(precision, scale); + } else if (type.isJsonbType()) { + return JsonType.INSTANCE; + } else if (type.isStructType()) { + return StructType.INSTANCE; + } else if (type.isMapType()) { + return MapType.INSTANCE; } else if (type.isArrayType()) { - return ArrayType.of(fromLegacyType(((org.apache.doris.catalog.ArrayType) type).getItemType())); + org.apache.doris.catalog.ArrayType arrayType = (org.apache.doris.catalog.ArrayType) type; + return ArrayType.of(fromCatalogType(arrayType.getItemType()), arrayType.getContainsNull()); } throw new AnalysisException("Nereids do not support type: " + type); } - public abstract Type toCatalogDataType(); - public abstract String toSql(); @Override @@ -277,14 +333,14 @@ public abstract class DataType implements AbstractDataType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return sameType(other); } /** * this and other is same type. */ - private boolean sameType(DataType other) { + private boolean sameType(AbstractDataType other) { return this.equals(other); } @@ -391,17 +447,85 @@ public abstract class DataType implements AbstractDataType { public abstract int width(); - private static Optional matchVarchar(String type) { + private static Optional matchChar(String type) { + Matcher matcher = CHAR_PATTERN.matcher(type); + if (matcher.find() && matcher.group().equals(type)) { + String len = matcher.group(2); + CharType charType = len != null + ? CharType.createCharType(Integer.valueOf(len)) + : CharType.SYSTEM_DEFAULT; + return Optional.of(charType); + } + return Optional.empty(); + } + + private static Optional matchVarchar(String type) { Matcher matcher = VARCHAR_PATTERN.matcher(type); - if (matcher.find()) { - VarcharType varcharType = matcher.groupCount() > 1 - ? VarcharType.createVarcharType(Integer.valueOf(matcher.group(1))) + if (matcher.find() && matcher.group().equals(type)) { + String scale = matcher.group(2); + VarcharType varcharType = scale != null + ? VarcharType.createVarcharType(Integer.valueOf(scale)) : VarcharType.SYSTEM_DEFAULT; return Optional.of(varcharType); } return Optional.empty(); } + private static Optional matchDateTime(String type) { + Matcher matcher = DATETIME_PATTERN.matcher(type); + if (matcher.find() && matcher.group().equals(type)) { + String scale = matcher.group(2); + return Optional.of( + fromCatalogType(scale != null + ? ScalarType.createDatetimeV2Type(Integer.valueOf(scale)) + : ScalarType.createDatetimeType()) + ); + } + matcher = DATETIMEV2_PATTERN.matcher(type); + if (matcher.find()) { + String scale = matcher.group(2); + return Optional.of( + fromCatalogType(scale != null + ? ScalarType.createDatetimeV2Type(Integer.valueOf(scale)) + : ScalarType.createDatetimeV2Type(0)) + ); + } + return Optional.empty(); + } + + private static Optional matchDecimalType(String type) { + Matcher matcher = DECIMAL_PATTERN.matcher(type); + if (matcher.find() && matcher.group().equals(type)) { + String precision = matcher.group(2); + String scale = matcher.group(4); + if (scale != null) { + return Optional.of(fromCatalogType( + ScalarType.createDecimalType(Integer.valueOf(precision), Integer.valueOf(scale)))); + } + + if (precision != null) { + return Optional.of(fromCatalogType(ScalarType.createDecimalType(Integer.valueOf(precision)))); + } + return Optional.of(fromCatalogType(ScalarType.createDecimalType())); + } + + matcher = DECIMALV3_PATTERN.matcher(type); + if (matcher.find() && matcher.group().equals(type)) { + String precision = matcher.group(2); + String scale = matcher.group(4); + if (scale != null) { + return Optional.of(fromCatalogType( + ScalarType.createDecimalV3Type(Integer.valueOf(precision), Integer.valueOf(scale)))); + } + + if (precision != null) { + return Optional.of(fromCatalogType(ScalarType.createDecimalV3Type(Integer.valueOf(precision)))); + } + return Optional.of(fromCatalogType(ScalarType.createDecimalV3Type())); + } + return Optional.empty(); + } + private static ArrayType resolveArrayType(String type) { if (!type.startsWith("array")) { throw new AnalysisException("Not array type: " + type); @@ -413,7 +537,7 @@ public abstract class DataType implements AbstractDataType { if (itemType.equals(NullType.INSTANCE)) { return ArrayType.SYSTEM_DEFAULT; } - return new ArrayType(itemType); + return ArrayType.of(itemType); } else if (type.isEmpty()) { return ArrayType.SYSTEM_DEFAULT; } else { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateTimeV2Type.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateTimeV2Type.java index 2fbb64658d..d21649142b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateTimeV2Type.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateTimeV2Type.java @@ -17,11 +17,14 @@ package org.apache.doris.nereids.types; +import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.Type; import org.apache.doris.nereids.types.coercion.PrimitiveType; import com.google.common.base.Preconditions; +import java.util.Objects; + /** * Datetime type in Nereids. */ @@ -38,14 +41,32 @@ public class DateTimeV2Type extends PrimitiveType { this.scale = scale; } + public static DateTimeV2Type of(int scale) { + if (scale == INSTANCE.scale) { + return INSTANCE; + } else { + return new DateTimeV2Type(scale); + } + } + @Override public Type toCatalogDataType() { - return Type.DATETIME; + return ScalarType.createDatetimeV2Type(scale); } @Override public boolean equals(Object o) { - return o instanceof DateTimeV2Type; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + DateTimeV2Type that = (DateTimeV2Type) o; + return Objects.equals(scale, that.scale); } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateV2Type.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateV2Type.java index 6d830d2ff5..4f5b808b84 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateV2Type.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateV2Type.java @@ -34,7 +34,7 @@ public class DateV2Type extends PrimitiveType { @Override public Type toCatalogDataType() { - return Type.DATE; + return Type.DATEV2; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalType.java index 9097a2d45c..545bdae390 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.FractionalType; import org.apache.doris.nereids.types.coercion.IntegralType; @@ -129,7 +130,7 @@ public class DecimalType extends FractionalType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof DecimalType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java index afb7da0664..56e89a291b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.FractionalType; import org.apache.doris.nereids.types.coercion.IntegralType; @@ -32,21 +33,20 @@ import java.util.Objects; * Decimal type in Nereids. */ public class DecimalV2Type extends FractionalType { + public static final int MAX_DECIMALV2_PRECISION = 27; + public static final int MAX_DECIMALV2_SCALE = 9; - public static int MAX_PRECISION = 38; - public static int MAX_SCALE = 38; - public static final DecimalV2Type SYSTEM_DEFAULT = new DecimalV2Type(9, 0); + public static final DecimalV2Type SYSTEM_DEFAULT = new DecimalV2Type(DEFAULT_PRECISION, 0); + public static final DecimalV2Type MAX = new DecimalV2Type(MAX_DECIMALV2_PRECISION, MAX_DECIMALV2_SCALE); private static final DecimalV2Type BOOLEAN_DECIMAL = new DecimalV2Type(1, 0); private static final DecimalV2Type TINYINT_DECIMAL = new DecimalV2Type(3, 0); private static final DecimalV2Type SMALLINT_DECIMAL = new DecimalV2Type(5, 0); private static final DecimalV2Type INTEGER_DECIMAL = new DecimalV2Type(10, 0); private static final DecimalV2Type BIGINT_DECIMAL = new DecimalV2Type(20, 0); - private static final DecimalV2Type LARGEINT_DECIMAL = new DecimalV2Type(38, 0); + private static final DecimalV2Type LARGEINT_DECIMAL = new DecimalV2Type(MAX_DECIMALV2_PRECISION, 0); private static final DecimalV2Type FLOAT_DECIMAL = new DecimalV2Type(14, 7); - private static final DecimalV2Type DOUBLE_DECIMAL = new DecimalV2Type(30, 15); - - private static final int WIDTH = 16; + private static final DecimalV2Type DOUBLE_DECIMAL = MAX; private static final Map FOR_TYPE_MAP = ImmutableMap.builder() .put(TinyIntType.INSTANCE, TINYINT_DECIMAL) @@ -58,27 +58,19 @@ public class DecimalV2Type extends FractionalType { .put(DoubleType.INSTANCE, DOUBLE_DECIMAL) .build(); + private static final int WIDTH = 16; + private final int precision; private final int scale; - public DecimalV2Type(int precision, int scale) { + private DecimalV2Type(int precision, int scale) { Preconditions.checkArgument(precision >= scale); - Preconditions.checkArgument(precision > 0 && precision <= MAX_PRECISION); - Preconditions.checkArgument(scale >= 0 && scale <= MAX_SCALE); + Preconditions.checkArgument(precision > 0 && precision <= MAX_DECIMALV2_PRECISION); + Preconditions.checkArgument(scale >= 0 && scale <= MAX_DECIMALV2_SCALE); this.precision = precision; this.scale = scale; } - public static DecimalV2Type createDecimalType(int precision, int scale) { - return new DecimalV2Type(Math.min(precision, MAX_PRECISION), Math.min(scale, MAX_SCALE)); - } - - public static DecimalV2Type createDecimalType(BigDecimal bigDecimal) { - int precision = org.apache.doris.analysis.DecimalLiteral.getBigDecimalPrecision(bigDecimal); - int scale = org.apache.doris.analysis.DecimalLiteral.getBigDecimalScale(bigDecimal); - return createDecimalType(precision, scale); - } - public static DecimalV2Type forType(DataType dataType) { if (FOR_TYPE_MAP.containsKey(dataType)) { return FOR_TYPE_MAP.get(dataType); @@ -86,20 +78,37 @@ public class DecimalV2Type extends FractionalType { throw new RuntimeException("Could not create decimal for type " + dataType); } - public static DecimalV2Type widerDecimalType(DecimalV2Type left, DecimalV2Type right) { - return widerDecimalType(left.getPrecision(), right.getPrecision(), left.getScale(), right.getScale()); + /** createDecimalV2Type. */ + public static DecimalV2Type createDecimalV2Type(int precision, int scale) { + if (precision == SYSTEM_DEFAULT.precision && scale == SYSTEM_DEFAULT.scale) { + return SYSTEM_DEFAULT; + } + if (precision == MAX.precision && scale == MAX.scale) { + return MAX; + } + return new DecimalV2Type(Math.min(precision, MAX_DECIMALV2_PRECISION), Math.min(scale, MAX_DECIMALV2_SCALE)); } - private static DecimalV2Type widerDecimalType(int leftPrecision, int rightPrecision, int leftScale, + public static DecimalV2Type createDecimalV2Type(BigDecimal bigDecimal) { + int precision = org.apache.doris.analysis.DecimalLiteral.getBigDecimalPrecision(bigDecimal); + int scale = org.apache.doris.analysis.DecimalLiteral.getBigDecimalScale(bigDecimal); + return createDecimalV2Type(precision, scale); + } + + public static DecimalV2Type widerDecimalV2Type(DecimalV2Type left, DecimalV2Type right) { + return widerDecimalV2Type(left.getPrecision(), right.getPrecision(), left.getScale(), right.getScale()); + } + + private static DecimalV2Type widerDecimalV2Type(int leftPrecision, int rightPrecision, int leftScale, int rightScale) { int scale = Math.max(leftScale, rightScale); int range = Math.max(leftPrecision - leftScale, rightPrecision - rightScale); - return DecimalV2Type.createDecimalType(range + scale, scale); + return DecimalV2Type.createDecimalV2Type(range + scale, scale); } @Override public Type toCatalogDataType() { - return Type.DECIMALV2; + return Type.MAX_DECIMALV2_TYPE; } public int getPrecision() { @@ -130,7 +139,7 @@ public class DecimalV2Type extends FractionalType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof DecimalV2Type; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java new file mode 100644 index 0000000000..1e831b9206 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java @@ -0,0 +1,187 @@ +// 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.types; + +import org.apache.doris.catalog.ScalarType; +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.annotation.Developing; +import org.apache.doris.nereids.types.coercion.AbstractDataType; +import org.apache.doris.nereids.types.coercion.FractionalType; +import org.apache.doris.nereids.types.coercion.IntegralType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; + +import java.math.BigDecimal; +import java.util.Map; +import java.util.Objects; + +/** + * Decimal type in Nereids. + */ +@Developing +public class DecimalV3Type extends FractionalType { + public static final int MAX_DECIMALV2_SCALE = 9; + public static final int MAX_DECIMAL32_PRECISION = 9; + public static final int MAX_DECIMAL64_PRECISION = 18; + public static final int MAX_DECIMAL128_PRECISION = 38; + + public static final DecimalV3Type DEFAULT_DECIMAL32 = new DecimalV3Type(DEFAULT_PRECISION, DEFAULT_SCALE); + public static final DecimalV3Type DEFAULT_DECIMAL64 = new DecimalV3Type(DEFAULT_PRECISION, DEFAULT_SCALE); + public static final DecimalV3Type DEFAULT_DECIMAL128 = new DecimalV3Type(MAX_DECIMAL128_PRECISION, DEFAULT_SCALE); + public static final DecimalV3Type SYSTEM_DEFAULT = DEFAULT_DECIMAL32; + + private static final DecimalV3Type BOOLEAN_DECIMAL = DEFAULT_DECIMAL32; + private static final DecimalV3Type TINYINT_DECIMAL = DEFAULT_DECIMAL32; + private static final DecimalV3Type SMALLINT_DECIMAL = DEFAULT_DECIMAL32; + private static final DecimalV3Type INTEGER_DECIMAL = DEFAULT_DECIMAL32; + private static final DecimalV3Type BIGINT_DECIMAL = DEFAULT_DECIMAL64; + private static final DecimalV3Type FLOAT_DECIMAL = DEFAULT_DECIMAL64; + private static final DecimalV3Type DOUBLE_DECIMAL = DEFAULT_DECIMAL128; + + private static final Map FOR_TYPE_MAP = ImmutableMap.builder() + .put(TinyIntType.INSTANCE, TINYINT_DECIMAL) + .put(SmallIntType.INSTANCE, SMALLINT_DECIMAL) + .put(IntegerType.INSTANCE, INTEGER_DECIMAL) + .put(BigIntType.INSTANCE, BIGINT_DECIMAL) + .put(LargeIntType.INSTANCE, DEFAULT_DECIMAL128) + .put(FloatType.INSTANCE, FLOAT_DECIMAL) + .put(DoubleType.INSTANCE, DOUBLE_DECIMAL) + .build(); + + private static final int WIDTH = 16; + + private final int precision; + private final int scale; + + private DecimalV3Type(int precision, int scale) { + Preconditions.checkArgument(precision > 0 && precision <= MAX_DECIMAL128_PRECISION); + this.precision = precision; + this.scale = scale; + } + + public static DecimalV3Type forType(DataType dataType) { + if (FOR_TYPE_MAP.containsKey(dataType)) { + return FOR_TYPE_MAP.get(dataType); + } + throw new RuntimeException("Could not create decimal for type " + dataType); + } + + /** createDecimalV3Type. */ + public static DecimalV3Type createDecimalV3Type(int precision) { + if (precision <= MAX_DECIMAL32_PRECISION) { + return DEFAULT_DECIMAL32; + } + if (precision <= MAX_DECIMAL64_PRECISION) { + return DEFAULT_DECIMAL64; + } + if (precision <= MAX_DECIMAL128_PRECISION) { + return DEFAULT_DECIMAL128; + } + + return new DecimalV3Type(Math.min(precision, MAX_DECIMAL128_PRECISION), DEFAULT_SCALE); + } + + public static DecimalV3Type createDecimalV3Type(BigDecimal bigDecimal) { + int precision = org.apache.doris.analysis.DecimalLiteral.getBigDecimalPrecision(bigDecimal); + return createDecimalV3Type(precision); + } + + public static DecimalV3Type widerDecimalV3Type(DecimalV3Type left, DecimalV3Type right) { + return widerDecimalV3Type(left.getPrecision(), right.getPrecision()); + } + + private static DecimalV3Type widerDecimalV3Type(int leftPrecision, int rightPrecision) { + int maxPrecision = Math.max(leftPrecision, rightPrecision); + return DecimalV3Type.createDecimalV3Type(maxPrecision); + } + + @Override + public Type toCatalogDataType() { + return ScalarType.createDecimalV3Type(precision, scale); + } + + public int getPrecision() { + return precision; + } + + public int getScale() { + return scale; + } + + public boolean isWiderThan(DataType other) { + return isWiderThanInternal(other); + } + + private boolean isWiderThanInternal(DataType other) { + if (other instanceof DecimalV3Type) { + DecimalV3Type dt = (DecimalV3Type) other; + return this.precision - this.scale >= dt.precision - dt.scale && this.scale >= dt.scale; + } else if (other instanceof IntegralType) { + return isWiderThanInternal(forType(other)); + } + return false; + } + + @Override + public DataType defaultConcreteType() { + return SYSTEM_DEFAULT; + } + + @Override + public boolean acceptsType(AbstractDataType other) { + return other instanceof DecimalV3Type; + } + + @Override + public String simpleString() { + return "decimal"; + } + + @Override + public String toSql() { + return "DECIMAL(" + precision + ", " + scale + ")"; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + DecimalV3Type that = (DecimalV3Type) o; + return precision == that.precision && scale == that.scale; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), precision, scale); + } + + @Override + public int width() { + return WIDTH; + } + +} + diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DoubleType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DoubleType.java index cbe52701c0..58959b8512 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DoubleType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DoubleType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.FractionalType; /** @@ -47,7 +48,7 @@ public class DoubleType extends FractionalType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof DoubleType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/FloatType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/FloatType.java index 394ba7be44..3dbfda4e7e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/FloatType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/FloatType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.FractionalType; /** @@ -42,7 +43,7 @@ public class FloatType extends FractionalType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof FloatType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/HllType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/HllType.java index b9a648a661..e0ad0e40cd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/HllType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/HllType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; /** * Bitmap type in Nereids. @@ -37,7 +38,7 @@ public class HllType extends DataType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof HllType; } @@ -63,6 +64,6 @@ public class HllType extends DataType { @Override public String toSql() { - return "BITMAP"; + return "HLL"; } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/IntegerType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/IntegerType.java index 71e418915b..2a118d455a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/IntegerType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/IntegerType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.IntegralType; /** @@ -47,7 +48,7 @@ public class IntegerType extends IntegralType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof IntegerType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/JsonType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/JsonType.java new file mode 100644 index 0000000000..5e5a15ef06 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/JsonType.java @@ -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.types; + +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.annotation.Developing; +import org.apache.doris.nereids.types.coercion.AbstractDataType; + +/** + * Json type in Nereids. + */ +@Developing +public class JsonType extends DataType { + + public static final JsonType INSTANCE = new JsonType(); + + public static final int WIDTH = 16; + + private JsonType() { + } + + @Override + public Type toCatalogDataType() { + return Type.QUANTILE_STATE; + } + + @Override + public boolean acceptsType(AbstractDataType other) { + return other instanceof JsonType; + } + + @Override + public String simpleString() { + return "json"; + } + + @Override + public DataType defaultConcreteType() { + return INSTANCE; + } + + @Override + public boolean equals(Object o) { + return o instanceof JsonType; + } + + @Override + public int width() { + return WIDTH; + } + + @Override + public String toSql() { + return "JSON"; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/LargeIntType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/LargeIntType.java index 19b7b638a7..9c5e1838b8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/LargeIntType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/LargeIntType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.IntegralType; /** @@ -47,7 +48,7 @@ public class LargeIntType extends IntegralType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof LargeIntType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/MapType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/MapType.java new file mode 100644 index 0000000000..40e0dae0fd --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/MapType.java @@ -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.types; + +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.annotation.Developing; +import org.apache.doris.nereids.types.coercion.AbstractDataType; + +/** + * Struct type in Nereids. + */ +@Developing +public class MapType extends DataType { + + public static final MapType INSTANCE = new MapType(); + + public static final int WIDTH = 24; + + private MapType() { + } + + @Override + public Type toCatalogDataType() { + return Type.MAP; + } + + @Override + public boolean acceptsType(AbstractDataType other) { + return other instanceof MapType; + } + + @Override + public String simpleString() { + return "map"; + } + + @Override + public DataType defaultConcreteType() { + return INSTANCE; + } + + @Override + public boolean equals(Object o) { + return o instanceof MapType; + } + + @Override + public int width() { + return WIDTH; + } + + @Override + public String toSql() { + return "MAP"; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/QuantileStateType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/QuantileStateType.java index c09721f348..91a8665b53 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/QuantileStateType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/QuantileStateType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; /** * Bitmap type in Nereids. @@ -37,7 +38,7 @@ public class QuantileStateType extends DataType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof QuantileStateType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/SmallIntType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/SmallIntType.java index 1c2d1d0e6c..a7053b2160 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/SmallIntType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/SmallIntType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.IntegralType; /** @@ -47,7 +48,7 @@ public class SmallIntType extends IntegralType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof SmallIntType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/StringType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/StringType.java index c9ccaca68c..c407603597 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/StringType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/StringType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.CharacterType; /** @@ -37,7 +38,7 @@ public class StringType extends CharacterType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof StringType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/StructType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/StructType.java new file mode 100644 index 0000000000..147bffdf5e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/StructType.java @@ -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.types; + +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.annotation.Developing; +import org.apache.doris.nereids.types.coercion.AbstractDataType; + +/** + * Struct type in Nereids. + */ +@Developing +public class StructType extends DataType { + + public static final StructType INSTANCE = new StructType(); + + public static final int WIDTH = 24; + + private StructType() { + } + + @Override + public Type toCatalogDataType() { + return Type.STRUCT; + } + + @Override + public boolean acceptsType(AbstractDataType other) { + return other instanceof StructType; + } + + @Override + public String simpleString() { + return "struct"; + } + + @Override + public DataType defaultConcreteType() { + return INSTANCE; + } + + @Override + public boolean equals(Object o) { + return o instanceof StructType; + } + + @Override + public int width() { + return WIDTH; + } + + @Override + public String toSql() { + return "STRUCT"; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TextType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TextType.java index becbbd940c..c8d5193666 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TextType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TextType.java @@ -19,12 +19,13 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.CharacterType; import java.util.Objects; /** - * Varchar type in Nereids. + * Text type in Nereids. */ public class TextType extends CharacterType { @@ -44,13 +45,13 @@ public class TextType extends CharacterType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof TextType; } @Override public String simpleString() { - return "varchar"; + return "text"; } @Override @@ -60,7 +61,7 @@ public class TextType extends CharacterType { @Override public String toSql() { - return "VARCHAR(" + len + ")"; + return "TEXT(" + len + ")"; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TimeV2Type.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TimeV2Type.java index cfc55aa0ba..f798a9b3f7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TimeV2Type.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TimeV2Type.java @@ -34,7 +34,7 @@ public class TimeV2Type extends PrimitiveType { @Override public Type toCatalogDataType() { - return Type.TIME; + return Type.TIMEV2; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TinyIntType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TinyIntType.java index 5729113025..76192ea509 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TinyIntType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/TinyIntType.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.IntegralType; /** @@ -47,7 +48,7 @@ public class TinyIntType extends IntegralType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof TinyIntType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/VarcharType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/VarcharType.java index a85ac8d708..febe614d4f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/VarcharType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/VarcharType.java @@ -19,6 +19,7 @@ package org.apache.doris.nereids.types; import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.types.coercion.AbstractDataType; import org.apache.doris.nereids.types.coercion.CharacterType; import java.util.Objects; @@ -47,7 +48,7 @@ public class VarcharType extends CharacterType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof VarcharType; } @@ -63,6 +64,9 @@ public class VarcharType extends CharacterType { @Override public String toSql() { + if (len == -1) { + return "VARCHAR(*)"; + } return "VARCHAR(" + len + ")"; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AbstractDataType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AbstractDataType.java index fa198be884..42cd1e9d07 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AbstractDataType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AbstractDataType.java @@ -17,6 +17,8 @@ package org.apache.doris.nereids.types.coercion; +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.annotation.Developing; import org.apache.doris.nereids.types.DataType; /** @@ -32,7 +34,13 @@ public interface AbstractDataType { /** * This AbstractDataType could accept other without implicit cast */ - boolean acceptsType(DataType other); + boolean acceptsType(AbstractDataType other); + + /** + * convert nereids's data type to legacy catalog data type + * @return legacy catalog data type + */ + Type toCatalogDataType(); /** * simple string used to print error message @@ -44,6 +52,7 @@ public interface AbstractDataType { * @param targetDataType the target data type * @return true if assignable */ + @Developing default boolean isAssignableFrom(AbstractDataType targetDataType) { if (this.equals(targetDataType)) { return true; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AnyDataType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AnyDataType.java index 3c8bafbaee..be07a7ee7b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AnyDataType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/AnyDataType.java @@ -17,6 +17,8 @@ package org.apache.doris.nereids.types.coercion; +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.types.DataType; /** @@ -32,10 +34,15 @@ public class AnyDataType implements AbstractDataType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return true; } + @Override + public Type toCatalogDataType() { + throw new AnalysisException("AnyDataType can not cast to catalog data type"); + } + @Override public String simpleString() { return "any"; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/CharacterType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/CharacterType.java index 95cc67249d..9c6d69866c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/CharacterType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/CharacterType.java @@ -46,7 +46,7 @@ public class CharacterType extends PrimitiveType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof CharacterType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/FractionalType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/FractionalType.java index bb3a30e228..abc8493d1d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/FractionalType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/FractionalType.java @@ -32,7 +32,7 @@ public class FractionalType extends NumericType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof FractionalType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/IntegralType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/IntegralType.java index 628e881198..7c147ff017 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/IntegralType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/IntegralType.java @@ -33,7 +33,7 @@ public class IntegralType extends NumericType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof IntegralType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/NumericType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/NumericType.java index 74733a1f1d..813bdf4e6f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/NumericType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/NumericType.java @@ -39,7 +39,7 @@ public class NumericType extends PrimitiveType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return other instanceof NumericType; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/TypeCollection.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/TypeCollection.java index 78753d8bf6..001e8115b7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/TypeCollection.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/coercion/TypeCollection.java @@ -17,6 +17,8 @@ package org.apache.doris.nereids.types.coercion; +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.types.CharType; import org.apache.doris.nereids.types.DataType; import org.apache.doris.nereids.types.StringType; @@ -63,10 +65,15 @@ public class TypeCollection implements AbstractDataType { } @Override - public boolean acceptsType(DataType other) { + public boolean acceptsType(AbstractDataType other) { return types.stream().anyMatch(t -> t.acceptsType(other)); } + @Override + public Type toCatalogDataType() { + throw new AnalysisException("TypeCollection can not cast to catalog data type"); + } + @Override public String simpleString() { return types.stream().map(AbstractDataType::simpleString).collect(Collectors.joining(" or ", "(", ")")); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/ResponsibilityChain.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/ResponsibilityChain.java new file mode 100644 index 0000000000..e5f8201675 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/ResponsibilityChain.java @@ -0,0 +1,97 @@ +// 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.util; + +import com.google.common.collect.Lists; + +import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * ResponsibilityChain. + * + * e.g. + *
+ *     ResponsibilityChain.from(defaultResult)
+ *          .then(computeA)
+ *          .then(computeB)
+ *          .then(computeC)
+ *          .get();
+ * 
+ * @param input type. + */ +public class ResponsibilityChain { + private T defaultResult; + private boolean assertNotNull; + private List> chain = Lists.newArrayList(); + + private ResponsibilityChain(T defaultResult) { + this.defaultResult = defaultResult; + } + + /** + * start to compute child by the input parameter. + * @param result type. + * @param defaultResult defaultResult + * @return result + */ + public static ResponsibilityChain from(T defaultResult) { + return new ResponsibilityChain(defaultResult); + } + + public ResponsibilityChain assertNotNull() { + this.assertNotNull = true; + return this; + } + + /** + * add a computed logic to the chain. + * @param computeFunction consume previous result, return new result + * @return this. + */ + public ResponsibilityChain then(Function computeFunction) { + chain.add(computeFunction); + return this; + } + + /** + * add a computed logic to the chain if you not care about the previous result. + * @param computeFunction return new result + * @return this. + */ + public ResponsibilityChain then(Supplier computeFunction) { + chain.add(previousResult -> computeFunction.get()); + return this; + } + + /** + * get result. + * @return result + */ + public T get() { + T result = defaultResult; + for (Function branchFunction : chain) { + result = branchFunction.apply(result); + } + if (result == null) { + throw new NullPointerException("Result can not be null"); + } + return result; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index 9e639f462a..9b08091eb9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -430,7 +430,7 @@ public class StmtExecutor implements ProfileWriter { throw e.getException(); } // fall back to legacy planner - LOG.info("fall back to legacy planner, because: {}", e.getMessage()); + LOG.warn("fall back to legacy planner, because: {}", e.getMessage(), e); parsedStmt = null; analyze(context.getSessionVariable().toThrift()); } @@ -716,11 +716,10 @@ public class StmtExecutor implements ProfileWriter { } catch (UserException e) { throw e; } catch (Exception e) { - e.printStackTrace(); - if (parsedStmt instanceof LogicalPlanAdapter) { - throw new NereidsException(new AnalysisException("Unexpected exception: " + e.getMessage())); - } LOG.warn("Analyze failed. {}", context.getQueryIdentifier(), e); + if (parsedStmt instanceof LogicalPlanAdapter) { + throw new NereidsException(new AnalysisException("Unexpected exception: " + e.getMessage(), e)); + } throw new AnalysisException("Unexpected exception: " + e.getMessage()); } finally { MetaLockUtils.readUnlockTables(tables); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/HavingClauseTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/HavingClauseTest.java index 26ebc39db5..dafa792c50 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/HavingClauseTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/HavingClauseTest.java @@ -364,9 +364,9 @@ public class HavingClauseTest extends AnalyzeCheckTestBase implements PatternMat Alias pk11 = new Alias(new ExprId(8), new Add(new Add(pk, Literal.of((byte) 1)), Literal.of((short) 1)), "((pk + 1) + 1)"); Alias pk2 = new Alias(new ExprId(9), new Add(pk, Literal.of((byte) 2)), "(pk + 2)"); Alias sumA1 = new Alias(new ExprId(10), new Sum(a1), "SUM(a1)"); - Alias countA11 = new Alias(new ExprId(11), new Add(new Count(a1, false), Literal.of(1L)), "(COUNT(a1) + 1)"); + Alias countA11 = new Alias(new ExprId(11), new Add(new Count(a1), Literal.of(1L)), "(COUNT(a1) + 1)"); Alias sumA1A2 = new Alias(new ExprId(12), new Sum(new Add(a1, a2)), "SUM((a1 + a2))"); - Alias v1 = new Alias(new ExprId(0), new Count(a2, false), "v1"); + Alias v1 = new Alias(new ExprId(0), new Count(a2), "v1"); PlanChecker.from(connectContext).analyze(sql) .matchesFromRoot( logicalProject( diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java index b2591c69bf..3dc7783579 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FunctionRegistryTest.java @@ -140,6 +140,11 @@ public class FunctionRegistryTest implements PatternMatchSupported { public ExtendFunction(Expression a1) { super("foo", a1); } + + @Override + public boolean hasVarArguments() { + return false; + } } public static class AmbiguousFunction extends BoundFunction implements UnaryExpression, PropagateNullable { @@ -150,5 +155,10 @@ public class FunctionRegistryTest implements PatternMatchSupported { public AmbiguousFunction(Literal a1) { super("abc", a1); } + + @Override + public boolean hasVarArguments() { + return false; + } } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/GenerateScalarFunction.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/GenerateScalarFunction.java index 026b4480c9..2f7dc1bf6c 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/GenerateScalarFunction.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/GenerateScalarFunction.java @@ -17,41 +17,72 @@ package org.apache.doris.nereids.rules.analysis; +import org.apache.doris.analysis.ArithmeticExpr; +import org.apache.doris.analysis.ArithmeticExpr.Operator; +import org.apache.doris.analysis.BinaryPredicate; +import org.apache.doris.analysis.DateLiteral; +import org.apache.doris.analysis.FunctionCallExpr; +import org.apache.doris.analysis.TimestampArithmeticExpr.TimeUnit; import org.apache.doris.catalog.ArrayType; import org.apache.doris.catalog.Function; import org.apache.doris.catalog.Function.NullableMode; import org.apache.doris.catalog.FunctionSet; +import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.catalog.ScalarFunction; +import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.Type; import org.apache.doris.common.Pair; import org.apache.doris.nereids.annotation.Developing; +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.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.DateTimeWithPrecision; +import org.apache.doris.nereids.trees.expressions.functions.DecimalSamePrecision; +import org.apache.doris.nereids.trees.expressions.functions.DecimalStddevPrecision; +import org.apache.doris.nereids.trees.expressions.functions.DecimalWiderPrecision; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.functions.IdenticalSignature; +import org.apache.doris.nereids.trees.expressions.functions.ImplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.functions.Nondeterministic; +import org.apache.doris.nereids.trees.expressions.functions.NullOrIdenticalSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; -import org.apache.doris.nereids.trees.expressions.functions.SignatureSupplier; +import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral; +import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; import org.apache.doris.nereids.trees.expressions.shape.LeafExpression; import org.apache.doris.nereids.trees.expressions.shape.TernaryExpression; import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DataType; import org.apache.doris.nereids.util.ExpressionUtils; import com.google.common.base.Preconditions; +import com.google.common.base.Suppliers; import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.CaseUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import java.io.File; +import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.nio.charset.StandardCharsets; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -59,22 +90,347 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.Set; import java.util.TreeMap; +import java.util.function.Supplier; import java.util.stream.Collectors; public class GenerateScalarFunction { + + static final Set unaryArithmeticOperators = Arrays.stream(ArithmeticExpr.Operator.values()) + .filter(ArithmeticExpr.Operator::isUnary) + .map(Operator::getName) + .collect(Collectors.toSet()); + + static final Set binaryArithmeticOperators = Arrays.stream(ArithmeticExpr.Operator.values()) + .filter(ArithmeticExpr.Operator::isBinary) + .map(Operator::getName) + .collect(Collectors.toSet()); + + static final Set binaryComparisonOperators = Arrays.stream(BinaryPredicate.Operator.values()) + .map(BinaryPredicate.Operator::getName) + .collect(Collectors.toSet()); + + static final Set binaryCompoundPredicateOperators = ImmutableSet.of("and", "or"); + + static final Set unaryCompoundPredicateOperators = ImmutableSet.of("not"); + + static final Set inPredicateOperators = ImmutableSet.of("in_iterate", "not_in_iterate", + "in_set_lookup", "not_in_set_lookup"); + + static final Set timestampOperators = ImmutableList.builder() + // the function name exists in TimestampArithmetic + .add( + "TIMESTAMPDIFF", + // add + "DATE_ADD", + "DAYS_ADD", + "ADDDATE", + "TIMESTAMPADD", + //sub + "DATE_SUB", + "DAYS_SUB", + "SUBDATE" + ) + // add other function which TimestampArithmetic.functionName is null + .addAll(Arrays.stream(TimeUnit.values()).map(unit -> unit.toString() + "S_ADD").collect(Collectors.toSet())) + .addAll(Arrays.stream(TimeUnit.values()).map(unit -> unit.toString() + "S_SUB").collect(Collectors.toSet())) + .build().stream().map(String::toLowerCase).collect(Collectors.toSet()); + + static final Set isNullOperators = ImmutableSet.of("is_null_pred", "is_not_null_pred"); + + static final Set likeOperators = ImmutableSet.of("like", "regexp"); + + static final Set groupingOperators = ImmutableSet.of("grouping", "grouping_id"); + + static final Set operators = ImmutableSet.builder() + .addAll(unaryArithmeticOperators) + .addAll(binaryArithmeticOperators) + .addAll(binaryComparisonOperators) + .addAll(binaryCompoundPredicateOperators) + .addAll(unaryCompoundPredicateOperators) + .addAll(inPredicateOperators) + .addAll(timestampOperators) + .addAll(isNullOperators) + .addAll(likeOperators) + .addAll(groupingOperators) + .build(); + + static final Set identicalSignatureFunctions = ImmutableSet.of( + "multiply", "divide", "mod", "int_divide", "add", "subtract", "bitand", "bitor", "bitxor", "factorial", + "grouping", "grouping_id" + ); + + static final Set nullOrIdenticalSignatureFunctions = ImmutableSet.of( + "is_null_pred", "is_not_null_pred" + ); + + static final Set implicitlyCastableSignatureFunctions = ImmutableSet.of( + "bitnot", "eq", "ne", "le", "ge", "lt", "gt", "eq_for_null" + ); + + static final Map aliasToName = ImmutableMap.builder() + .put("substr", "substring") + .put("ifnull", "nvl") + .put("rand", "random") + .put("add_months", "months_add") + .put("curdate", "current_date") + .put("ucase", "upper") + .put("lcase", "lower") + .build(); + + static final Map formatClassName = ImmutableMap.builder() + .put("localtimestamp", "LocalTimestamp") + .put("localtime", "LocalTime") + .put("weekofyear", "WeekOfYear") + .put("yearweek", "YearWeek") + .put("strright", "StrRight") + .put("strleft", "StrLeft") + .put("monthname", "MonthName") + .put("md5sum", "Md5Sum") + .put("makedate", "MakeDate") + .put("datediff", "DateDiff") + .put("timediff", "TimeDiff") + .put("dayofmonth", "DayOfMonth") + .put("dayofweek", "DayOfWeek") + .put("dayofyear", "DayOfYear") + .put("datev2", "DateV2") + .put("dayname", "DayName") + .put("esquery", "EsQuery") + .put("nullif", "NullIf") + .put("to_datev2", "ToDateV2") + .build(); + + static final Set customNullableFunctions = ImmutableSet.of("if", "ifnull", "nvl", "coalesce", + "concat_ws", "rand", "random", "unix_timestamp"); + + static final List customCodeGenerators = ImmutableList.of( + new GenIf(), + new GenNvl(), + new GenCoalesce(), + new GenConcatWs(), + new GenRandom(), + new GenUnixTimestamp(), + new GenStrToDate(), + new GenSubstring() + ); + + static final Set customCastFunctions = ImmutableSet.of("%element_extract%", "concat_ws", "str_to_date"); + + static boolean isIdenticalSignature(String functionName) { + return functionName.startsWith("castto") || identicalSignatureFunctions.contains(functionName); + } + + static boolean isNullOrIdenticalSignature(String functionName) { + return nullOrIdenticalSignatureFunctions.contains(functionName); + } + + static boolean isImplicitlyCastableSignature(String functionName) { + return implicitlyCastableSignatureFunctions.contains(functionName); + } + + static boolean isArrayFunction(Function function) { + return function.getReturnType().isArrayType() || Arrays.stream(function.getArgs()).anyMatch(Type::isArrayType); + } + @Test @Disabled @Developing - public void test() { + public void generate() throws IOException { + Map scalarFunctionCodes = collectScalarFunctionCodes(); + // Pair> + List>> codeInfos = scalarFunctionCodes.entrySet() + .stream() + .map(kv -> Pair.of(getClassName(kv.getKey()), Pair.of(kv.getKey(), kv.getValue()))) + .sorted(Comparator.comparing(Pair::key)) + .collect(Collectors.toList()); + + generateFunctionsFile(codeInfos); + + generateScalarFunctionVisitorFile(codeInfos); + + generateBuiltinScalarFunctionsFile(codeInfos); + } + + private void generateFunctionsFile(List>> codesInfo) throws IOException { + File scalarFunPath = new File(getClass().getResource("/").getFile(), + "../generated-sources/org/apache/doris/nereids/trees/expressions/functions/scalar"); + scalarFunPath.mkdirs(); + for (Pair> codeInfo : codesInfo) { + String className = codeInfo.key(); + String code = codeInfo.value().value(); + File functionFile = new File(scalarFunPath, className + ".java"); + if (!functionFile.exists()) { + functionFile.createNewFile(); + FileUtils.writeStringToFile(functionFile, code, StandardCharsets.UTF_8); + } + } + } + + private void generateBuiltinScalarFunctionsFile(List>> codesInfo) throws IOException { + File catalogPath = new File(getClass().getResource("/").getFile(), + "../generated-sources/org/apache/doris/catalog"); + catalogPath.mkdirs(); + + List importFunctions = Lists.newArrayList(); + codesInfo.forEach(kv -> { + importFunctions.add("org.apache.doris.nereids.trees.expressions.functions.scalar." + kv.first); + }); + importFunctions.sort(this::sortImportPackageByCheckStyle); + + Multimap aliasReverseMap = aliasReverseMap(); + List registerCodes = Lists.newArrayList(); + for (Pair> info : codesInfo) { + String className = info.key(); + String functionName = info.value().key(); + + Collection aliases = aliasReverseMap.get(functionName); + List aliasList = Lists.newArrayList(functionName); + aliasList.addAll(aliases); + + String alias = aliasList.stream() + .sorted() + .map(s -> '"' + s + '"') + .collect(Collectors.joining(", ")); + Collections.sort(aliasList); + + registerCodes.add("scalar(" + className + ".class, " + alias + ")"); + } + + String code = "// Licensed to the Apache Software Foundation (ASF) under one\n" + + "// or more contributor license agreements. See the NOTICE file\n" + + "// distributed with this work for additional information\n" + + "// regarding copyright ownership. The ASF licenses this file\n" + + "// to you under the Apache License, Version 2.0 (the\n" + + "// \"License\"); you may not use this file except in compliance\n" + + "// with the License. You may obtain a copy of the License at\n" + + "//\n" + + "// http://www.apache.org/licenses/LICENSE-2.0\n" + + "//\n" + + "// Unless required by applicable law or agreed to in writing,\n" + + "// software distributed under the License is distributed on an\n" + + "// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" + + "// KIND, either express or implied. See the License for the\n" + + "// specific language governing permissions and limitations\n" + + "// under the License.\n" + + "\n" + + "package org.apache.doris.catalog;\n" + + "\n" + + importFunctions.stream().map(i -> "import " + i + ";\n").collect(Collectors.joining()) + + "\n" + + "import com.google.common.collect.ImmutableList;\n" + + "\n" + + "import java.util.List;\n" + + "\n" + + "/**\n" + + " * Builtin scalar functions.\n" + + " *\n" + + " * Note: Please ensure that this class only has some lists and no procedural code.\n" + + " * It helps to be clear and concise.\n" + + " */\n" + + "public class BuiltinScalarFunctions implements FunctionHelper {\n" + + " public final List scalarFunctions = ImmutableList.of(\n" + + registerCodes.stream().map(r -> " " + r).collect(Collectors.joining(",\n", "", "\n")) + + " );\n" + + "\n" + + " public static final BuiltinScalarFunctions INSTANCE = new BuiltinScalarFunctions();\n" + + "\n" + + " // Note: Do not add any code here!\n" + + " private BuiltinScalarFunctions() {}\n" + + "}\n"; + + FileUtils.writeStringToFile(new File(catalogPath, "BuiltinScalarFunctions.java"), code, StandardCharsets.UTF_8); + } + + private Multimap aliasReverseMap() { + ArrayListMultimap multimap = ArrayListMultimap.create(); + for (Entry entry : aliasToName.entrySet()) { + multimap.put(entry.getValue(), entry.getKey()); + } + return multimap; + } + + private void generateScalarFunctionVisitorFile(List>> codesInfo) throws IOException { + + File visitorPath = new File(getClass().getResource("/").getFile(), + "../generated-sources/org/apache/doris/nereids/trees/expressions/visitor"); + visitorPath.mkdirs(); + + List importFunctions = Lists.newArrayList("org.apache.doris.nereids.trees.expressions.functions.scalar.ScalarFunction"); + codesInfo.forEach(kv -> { + importFunctions.add("org.apache.doris.nereids.trees.expressions.functions.scalar." + kv.first); + }); + + importFunctions.sort(this::sortImportPackageByCheckStyle); + + String code = + "// Licensed to the Apache Software Foundation (ASF) under one\n" + + "// or more contributor license agreements. See the NOTICE file\n" + + "// distributed with this work for additional information\n" + + "// regarding copyright ownership. The ASF licenses this file\n" + + "// to you under the Apache License, Version 2.0 (the\n" + + "// \"License\"); you may not use this file except in compliance\n" + + "// with the License. You may obtain a copy of the License at\n" + + "//\n" + + "// http://www.apache.org/licenses/LICENSE-2.0\n" + + "//\n" + + "// Unless required by applicable law or agreed to in writing,\n" + + "// software distributed under the License is distributed on an\n" + + "// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" + + "// KIND, either express or implied. See the License for the\n" + + "// specific language governing permissions and limitations\n" + + "// under the License.\n" + + "\n" + + "package org.apache.doris.nereids.trees.expressions.visitor;\n" + + "\n"; + + for (String importFunction : importFunctions) { + code += "import " + importFunction + ";\n"; + } + + code += "\n" + + "/** ScalarFunctionVisitor. */\n" + + "public interface ScalarFunctionVisitor {\n" + + "\n" + + " R visitScalarFunction(ScalarFunction scalarFunction, C context);\n" + + "\n"; + + for (Pair> kv : codesInfo) { + code += generateVisitMethod(kv.key()) + "\n"; + } + code = code.trim() + "\n}\n"; + FileUtils.writeStringToFile(new File(visitorPath, "ScalarFunctionVisitor.java"), code, StandardCharsets.UTF_8); + } + + private String generateVisitMethod(String className) { + String instanceName = className.substring(0, 1).toLowerCase() + className.substring(1); + + if (instanceName.equals("if") || instanceName.length() > 20) { + instanceName = "function"; + } + return " default R visit" + className + "(" + className + " " + instanceName + ", C context) {\n" + + " return visitScalarFunction(" + instanceName + ", context);\n" + + " }\n"; + } + + private Map collectScalarFunctionCodes() { FunctionSet functionSet = new FunctionSet<>(); functionSet.init(); ArrayListMultimap scalarFunctionMap = ArrayListMultimap.create(); for (Entry> kv : functionSet.getVectorizedFunctions().entrySet()) { String functionName = kv.getKey(); + if (aliasToName.containsKey(functionName)) { + continue; + } for (Function function : kv.getValue()) { - if (function instanceof ScalarFunction && function.isUserVisible()) { - scalarFunctionMap.put(functionName, (ScalarFunction) function); + if (function instanceof ScalarFunction) { + // if (function.getArgs().length == 1 && function.getArgs()[0].isDatetimeV2()) { + // System.out.println(function.getReturnType() + " " + functionName + "(datetimev2)"); + // } + ScalarFunction scalarFunction = (ScalarFunction) function; + if (operators.contains(functionName) || functionName.startsWith("castto") || isArrayFunction(function)) { + continue; + } + scalarFunctionMap.put(functionName, scalarFunction); } } } @@ -88,6 +444,9 @@ public class GenerateScalarFunction { Map>> name2Functions = Maps.newTreeMap(); for (ScalarFunction functionInfo : scalarFunctionInfo) { String functionName = functionInfo.getFunctionName().getFunction(); + if (aliasToName.containsKey(functionName)) { + continue; + } Map> arity2Functions = name2Functions.get(functionName); if (arity2Functions == null) { arity2Functions = new TreeMap<>(); @@ -101,16 +460,17 @@ public class GenerateScalarFunction { functionInfos.add(functionInfo); } - Set customNullableFunctions = ImmutableSet.of("if", "ifnull", "nvl", "coalesce", - "concat_ws", "rand", "random", "unix_timestamp"); + Map name2Generator = customCodeGenerators.stream() + .collect(Collectors.toMap( + FunctionCodeGenerator::getFunctionName, + java.util.function.Function.identity()) + ); - List codes = name2Functions + return name2Functions .entrySet() .stream() + .sorted(Comparator.comparing(Entry::getKey)) .map(kv -> { - if (kv.getKey().startsWith("castto") || customNullableFunctions.contains(kv.getKey())) { - return ""; - } List scalarFunctions = Lists.newArrayList(); for (List functions : kv.getValue().values()) { for (ScalarFunction function : functions) { @@ -119,62 +479,149 @@ public class GenerateScalarFunction { } } } - String code = generateScalarFunctions(scalarFunctions, functionSet); + String code = generateScalarFunctions(kv.getKey(), scalarFunctions, functionSet, name2Generator); if (code.isEmpty()) { - throw new IllegalStateException("can not generate code for " + scalarFunctions.get(0).functionName()); + throw new IllegalStateException( + "can not generate code for " + scalarFunctions.get(0).functionName()); } - return code; + return Pair.of(kv.getKey(), code); }) - .filter(code -> !code.isEmpty()) - .collect(Collectors.toList()); + .collect(Collectors.toMap(Pair::key, Pair::value)); - // work in process, remove print in the future - System.out.println(codes); } - private String generateScalarFunctions(List scalarFunctions, FunctionSet functionSet) { + private String getClassName(String functionName) { + String className = formatClassName.get(functionName); + if (className == null) { + className = CaseUtils.toCamelCase(functionName.replaceAll("%", ""), true, '_'); + } + return className; + } + + private String generateScalarFunctions(String functionName, List scalarFunctions, + FunctionSet functionSet, Map name2Generator) { checkScalarFunctions(scalarFunctions); - ScalarFunction scalarFunction = scalarFunctions.get(0); - - String functionName = scalarFunction.getFunctionName().getFunction(); - String className = CaseUtils.toCamelCase(functionName.replaceAll("%", ""), true, '_'); + String className = getClassName(functionName); boolean hasVarArg = scalarFunctions.stream().anyMatch(ScalarFunction::hasVarArgs); + if (hasVarArg && !scalarFunctions.stream().allMatch(ScalarFunction::hasVarArgs)) { + throw new IllegalStateException("can not generate"); + } List interfaces = getInterfaces(functionName, hasVarArg, scalarFunctions, functionSet); String interfaceStr = interfaces.isEmpty() ? "" - : " implements " + interfaces.stream() + : "\n implements " + interfaces.stream() .map(Class::getSimpleName) .collect(Collectors.joining(", ")); - String code = generateScalarFunctionHeader(hasVarArg, interfaces) + Optional generator = Optional.ofNullable(name2Generator.get(functionName)); + + Set imports = Sets.newHashSet(ExpressionVisitor.class); + if (generator.isPresent()) { + imports.addAll(generator.get().imports()); + } + + List signatures = generateSignatures(scalarFunctions, imports); + + String extendsClass = "ScalarFunction"; + if (FunctionCallExpr.TIME_FUNCTIONS_WITH_PRECISION.contains(functionName)) { + extendsClass = "DateTimeWithPrecision"; + imports.add(DateTimeWithPrecision.class); + } + + String code = generateScalarFunctionHeader(scalarFunctions, hasVarArg, interfaces, imports) + "/**\n" + " * ScalarFunction '" + functionName + "'. This class is generated by GenerateScalarFunction.\n" - + " */\n" - + "public class " + className + " extends ScalarFunction" + interfaceStr + " {\n"; + + " */\n"; - code += "\n" - + " public static final List SIGNATURES = ImmutableList.of(\n"; - - List signatures = Lists.newArrayList(); - for (ScalarFunction function : scalarFunctions) { - String returnType = getDataTypeAndInstance(function.getReturnType()).second; - String args = Arrays.stream(function.getArgs()) - .map(type -> getDataTypeAndInstance(type).second) - .collect(Collectors.joining(", ")); - String buildArgs = function.hasVarArgs() ? "varArgs" : "args"; - signatures.add(" FuncSig.ret(" + returnType + ")." + buildArgs + "(" + args + ")"); + if (generator.isPresent()) { + code += generator.get().classComment(); } + code += "public class " + className + " extends " + extendsClass + interfaceStr + " {\n" + + "\n" + + " public static final List SIGNATURES = ImmutableList.of(\n"; code += StringUtils.join(signatures, ",\n") + "\n" + " );\n" - + "\n" - + generateConstructors(className, scalarFunctions) - + generateWithChildren(className, hasVarArg, scalarFunctions); + + "\n"; - return code + "}\n"; + if (generator.isPresent()) { + code += generator.get().fields(); + } + + code += generateConstructors(className, scalarFunctions); + + if (generator.isPresent()) { + code += generator.get().computeSignature(); + } + + if (generator.isPresent()) { + code += generator.get().nullable(); + } else if (customNullableFunctions.contains(functionName)) { + throw new IllegalStateException("custom nullable function should contains code generator"); + } + + if (generator.isPresent()) { + code += generator.get().methods(); + } + + code += generateWithChildren(className, hasVarArg, scalarFunctions); + + if (!signatures.isEmpty()) { + code += " @Override\n" + + " public List getSignatures() {\n" + + " return SIGNATURES;\n" + + " }\n" + + "\n"; + } + + code += generateAccept(className); + + return code.trim() + "\n}\n"; + } + + private List generateSignatures(List scalarFunctions, Set imports) { + List signatures = Lists.newArrayList(); + for (ScalarFunction function : scalarFunctions) { + imports.add(DataType.fromCatalogType(function.getReturnType()).getClass()); + String returnType = getDataTypeAndInstance(function.getReturnType()).second; + String args = Arrays.stream(function.getArgs()) + .map(type -> { + imports.add(DataType.fromCatalogType(type).getClass()); + return getDataTypeAndInstance(type).second; + }) + .collect(Collectors.joining(", ")); + String buildArgs = function.hasVarArgs() ? "varArgs" : "args"; + String signature = " FunctionSignature.ret(" + returnType + ")." + buildArgs + "(" + args + ")"; + if (signature.length() <= 119) { + signatures.add(signature); + continue; + } + + String returnLine = " FunctionSignature.ret(" + returnType + ")\n"; + String argumentsLine = " ." + buildArgs + "(" + args + ")"; + if (argumentsLine.length() <= 119) { + signatures.add(returnLine + argumentsLine); + continue; + } + + String[] arguments = args.split(", "); + String oneArgumentOneLine = Arrays.stream(arguments).collect(Collectors.joining(",\n" + + " ")); + signatures.add(" FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)\n" + + " .args(" + oneArgumentOneLine + ")"); + } + return signatures; + } + + private String generateAccept(String className) { + return " @Override\n" + + " public R accept(ExpressionVisitor visitor, C context) {\n" + + " return visitor.visit" + className + "(this, context);\n" + + " }\n" + + "\n"; } private List getInterfaces(String functionName, boolean hasVarArgs, @@ -188,23 +635,45 @@ public class GenerateScalarFunction { if (arityExpressionType != null) { interfaces.add(arityExpressionType); } - interfaces.add(SignatureSupplier.class); + interfaces.add(getComputeSignatureInterface(functionName)); + if (functionSet.isNondeterministicFunction(functionName)) { + interfaces.add(Nondeterministic.class); + } ScalarFunction scalarFunction = scalarFunctions.get(0); - boolean isPropagateNullable = scalarFunction.getNullableMode() == NullableMode.DEPEND_ON_ARGUMENT - || functionSet.isNullResultWithOneNullParamFunctions(functionName); - if (isPropagateNullable) { - interfaces.add(PropagateNullable.class); - } else if (scalarFunction.getNullableMode() == NullableMode.ALWAYS_NULLABLE) { - interfaces.add(AlwaysNullable.class); - } else if (scalarFunction.getNullableMode() == NullableMode.ALWAYS_NOT_NULLABLE) { - interfaces.add(AlwaysNotNullable.class); - } else { - throw new IllegalStateException("Not support compute custom nullable property: " + functionName); + if (!customNullableFunctions.contains(functionName)) { + boolean isPropagateNullable = scalarFunction.getNullableMode() == NullableMode.DEPEND_ON_ARGUMENT; + if (isPropagateNullable && !functionName.equals("substring")) { + interfaces.add(PropagateNullable.class); + } else if (scalarFunction.getNullableMode() == NullableMode.ALWAYS_NULLABLE || functionName.equals("substring")) { + interfaces.add(AlwaysNullable.class); + } else if (scalarFunction.getNullableMode() == NullableMode.ALWAYS_NOT_NULLABLE) { + interfaces.add(AlwaysNotNullable.class); + } + } + + if (FunctionCallExpr.DECIMAL_SAME_TYPE_SET.contains(functionName)) { + interfaces.add(DecimalSamePrecision.class); + } else if (FunctionCallExpr.DECIMAL_WIDER_TYPE_SET.contains(functionName)) { + interfaces.add(DecimalWiderPrecision.class); + } else if (FunctionCallExpr.STDDEV_FUNCTION_SET.contains(functionName)) { + interfaces.add(DecimalStddevPrecision.class); } return interfaces; } + private Class getComputeSignatureInterface(String functionName) { + if (isIdenticalSignature(functionName)) { + return IdenticalSignature.class; + } else if (isNullOrIdenticalSignature(functionName)) { + return NullOrIdenticalSignature.class; + } else if (isImplicitlyCastableSignature(functionName)) { + return ImplicitlyCastableSignature.class; + } else { + return ExplicitlyCastableSignature.class; + } + } + private String generateWithChildren(String className, boolean hasVarArg, List scalarFunctions) { Optional minVarArity = scalarFunctions.stream() .filter(ScalarFunction::hasVarArgs) @@ -221,7 +690,7 @@ public class GenerateScalarFunction { + " * withChildren.\n" + " */\n" + " @Override\n" - + " public Expression withChildren(List children) {\n"; + + " public " + className + " withChildren(List children) {\n"; List argumentNumChecks = Lists.newArrayList(); if (hasVarArg) { argumentNumChecks.add("children.size() >= " + minVarArity.get()); @@ -305,7 +774,7 @@ public class GenerateScalarFunction { } } } - code += " }\n"; + code += " }\n\n"; return code; } @@ -347,13 +816,16 @@ public class GenerateScalarFunction { for (int i = 1; i < scalarFunctions.size(); i++) { Assertions.assertEquals(functionName, scalarFunctions.get(i).getFunctionName().getFunction()); - Assertions.assertEquals(nullableMode, scalarFunctions.get(i).getNullableMode(), - scalarFunctions.get(0).functionName() + " nullable mode not consistent"); + + if (!customNullableFunctions.contains(functionName)) { + Assertions.assertEquals(nullableMode, scalarFunctions.get(i).getNullableMode(), + scalarFunctions.get(0).functionName() + " nullable mode not consistent"); + } } } private Pair getDataTypeAndInstance(Type type) { - DataType dataType = DataType.fromLegacyType(type); + DataType dataType = DataType.fromCatalogType(type); String dataTypeClassName = dataType.getClass().getSimpleName(); try { Field instanceField = dataType.getClass().getDeclaredField("INSTANCE"); @@ -380,6 +852,19 @@ public class GenerateScalarFunction { // skip exception } + try { + Field maxField = dataType.getClass().getDeclaredField("MAX"); + if (Modifier.isPublic(maxField.getModifiers()) + && Modifier.isStatic(maxField.getModifiers())) { + Object max = maxField.get(null); + if (max == dataType) { + return Pair.of(dataTypeClassName, dataTypeClassName + ".MAX"); + } + } + } catch (Throwable t) { + // skip exception + } + if (type.isArrayType()) { Type itemType = ((ArrayType) type).getItemType(); return Pair.of("ArrayType", "ArrayType.of(" + getDataTypeAndInstance(itemType).second + ")"); @@ -448,27 +933,46 @@ public class GenerateScalarFunction { params.add("children.get(" + i + ")"); } if (isVarArg) { - params.add("children.subList(" + arity + ", children.size()).toArray(new Expression[0])"); + return StringUtils.join(params, ", ") + + ",\n children.subList(" + arity + ", children.size()).toArray(new Expression[0])"; + } else { + return StringUtils.join(params, ", "); } - return StringUtils.join(params, ", "); } - private String generateScalarFunctionHeader(boolean hasVarArgs, List interfaces) { + private String generateScalarFunctionHeader(List scalarFunctions, + boolean hasVarArgs, List interfaces, Set imports) { List importDorisClasses = Lists.newArrayList( - interfaces.stream().filter(i -> i.getPackage().getName().startsWith("org.apache.doris")).collect( - Collectors.toList() + interfaces.stream() + .filter(i -> i.getPackage().getName().startsWith("org.apache.doris")) + .collect(Collectors.toList() ) ); + importDorisClasses.addAll(imports.stream() + .filter(i -> i.getPackage().getName().startsWith("org.apache.doris")) + .collect(Collectors.toList())); + List importThirdPartyClasses = Lists.newArrayList( + interfaces.stream() + .filter(i -> !i.getPackage().getName().startsWith("org.apache.doris") + && !i.getPackage().getName().startsWith("java.")) + .collect(Collectors.toList() + ) + ); + importThirdPartyClasses.addAll(imports.stream() + .filter(i -> !i.getPackage().getName().startsWith("org.apache.doris") + && !i.getPackage().getName().startsWith("java.")) + .collect(Collectors.toList())); + + importDorisClasses.add(Expression.class); + if (!scalarFunctions.isEmpty()) { + importDorisClasses.add(FunctionSignature.class); + importThirdPartyClasses.add(ImmutableList.class); + } if (hasVarArgs) { importDorisClasses.add(ExpressionUtils.class); } - List importThirdPartyClasses = Lists.newArrayList( - interfaces.stream().filter(i -> !i.getPackage().getName().startsWith("org.apache.doris")).collect( - Collectors.toList() - ) - ); if (!interfaces.contains(LeafExpression.class)) { importThirdPartyClasses.add(Preconditions.class); } @@ -495,17 +999,358 @@ public class GenerateScalarFunction { if (!importDorisClasses.isEmpty()) { code += importDorisClasses.stream() - .sorted((c1, c2) -> Ordering.natural().compare(c1.getName(), c2.getName())) + // sort import package by the checkstyle + .sorted(Comparator.comparing(Class::getName, this::sortImportPackageByCheckStyle)) .map(c -> "import " + c.getName() + ";\n") .collect(Collectors.joining("")) + "\n"; } if (!importThirdPartyClasses.isEmpty()) { code += importThirdPartyClasses.stream() - .sorted((c1, c2) -> Ordering.natural().compare(c1.getName(), c2.getName())) + .sorted(Comparator.comparing(Class::getName, this::sortImportPackageByCheckStyle)) + .map(c -> "import " + c.getName() + ";\n") + .collect(Collectors.joining("")) + "\n"; + } + + Set importJdkClasses = Sets.newHashSet(); + importJdkClasses.addAll(imports.stream() + .filter(i -> i.getPackage().getName().startsWith("java.")) + .collect(Collectors.toList())); + + if (!scalarFunctions.isEmpty() || !interfaces.contains(LeafExpression.class)) { + importJdkClasses.add(List.class); + } + if (!importJdkClasses.isEmpty()) { + code += importJdkClasses.stream() + .sorted(Comparator.comparing(Class::getName, this::sortImportPackageByCheckStyle)) .map(c -> "import " + c.getName() + ";\n") .collect(Collectors.joining("")) + "\n"; } return code; } + + private int sortImportPackageByCheckStyle(String c1, String c2) { + String[] p1 = c1.split("\\."); + String[] p2 = c2.split("\\."); + + for (int i = 0; i < Math.min(p1.length, p2.length); ++i) { + boolean leftIsClassName = i + 1 == p1.length; + boolean rightIsClassName = i + 1 == p2.length; + + if (leftIsClassName && rightIsClassName) { + return p1[i].compareTo(p2[i]); + } else if (leftIsClassName) { + // left package name is shorter than right package name + return -1; + } else if (rightIsClassName) { + // right package name is shorter than left package name + return 1; + } else { + int result = p1[i].compareTo(p2[i]); + if (result != 0) { + return result; + } + } + } + if (p1.length < p2.length) { + return -1; + } else if (p1.length > p2.length) { + return 1; + } else { + return 0; + } + } + + static class FunctionCodeGenerator { + public final String functionName; + + public FunctionCodeGenerator(String functionName) { + this.functionName = functionName; + } + + public String getFunctionName() { + return functionName; + } + + public List imports() { + return ImmutableList.of(); + } + + public String classComment() { + return ""; + } + + public String fields() { + return ""; + } + + public String methods() { + return ""; + } + + public String computeSignature() { + return ""; + } + + public String nullable() { + return ""; + } + } + + static class GenIf extends FunctionCodeGenerator { + public GenIf() { + super("if"); + } + + @Override + public List imports() { + return ImmutableList.of(Type.class, ScalarType.class, Supplier.class, Suppliers.class, DataType.class); + } + + @Override + public String fields() { + return " private final Supplier widerType = Suppliers.memoize(() -> {\n" + + " List argumentsTypes = getSignature().argumentsTypes;\n" + + " Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType(\n" + + " argumentsTypes.get(1).toCatalogDataType(),\n" + + " argumentsTypes.get(2).toCatalogDataType(),\n" + + " true);\n" + + " return DataType.fromCatalogType(assignmentCompatibleType);\n" + + " });\n" + + "\n"; + } + + @Override + public String computeSignature() { + return " @Override\n" + + " protected FunctionSignature computeSignature(FunctionSignature signature) {\n" + + " DataType widerType = this.widerType.get();\n" + + " signature = signature.withArgumentTypes(children(), (sigType, argType) -> widerType)\n" + + " .withReturnType(widerType);\n" + + " return super.computeSignature(signature);\n" + + " }\n" + + "\n"; + } + + @Override + public String nullable() { + return " /**\n" + + " * custom compute nullable.\n" + + " */\n" + + " @Override\n" + + " public boolean nullable() {\n" + + " for (int i = 1; i < arity(); i++) {\n" + + " if (child(i).nullable()) {\n" + + " return true;\n" + + " }\n" + + " }\n" + + " return false;\n" + + " }\n" + + "\n"; + } + } + + static class GenNvl extends FunctionCodeGenerator { + public GenNvl() { + super("nvl"); + } + + @Override + public String nullable() { + return " /**\n" + + " * custom compute nullable.\n" + + " */\n" + + " @Override\n" + + " public boolean nullable() {\n" + + " return child(0).nullable() && child(1).nullable();\n" + + " }\n" + + "\n"; + } + } + + static class GenCoalesce extends FunctionCodeGenerator { + public GenCoalesce() { + super("coalesce"); + } + + @Override + public String nullable() { + return " /**\n" + + " * custom compute nullable.\n" + + " */\n" + + " @Override\n" + + " public boolean nullable() {\n" + + " for (Expression argument : children) {\n" + + " if (!argument.nullable()) {\n" + + " return false;\n" + + " }\n" + + " }\n" + + " return true;\n" + + " }\n" + + "\n"; + } + } + + static class GenConcatWs extends FunctionCodeGenerator { + public GenConcatWs() { + super("concat_ws"); + } + + @Override + public String nullable() { + return " /**\n" + + " * custom compute nullable.\n" + + " */\n" + + " @Override\n" + + " public boolean nullable() {\n" + + " return child(0).nullable();\n" + + " }\n" + + "\n"; + } + } + + static class GenRandom extends FunctionCodeGenerator { + public GenRandom() { + super("random"); + } + + @Override + public String nullable() { + return " /**\n" + + " * custom compute nullable.\n" + + " */\n" + + " @Override\n" + + " public boolean nullable() {\n" + + " if (arity() > 0) {\n" + + " return children().stream().anyMatch(Expression::nullable);\n" + + " } else {\n" + + " return false;\n" + + " }\n" + + " }\n" + + "\n"; + } + } + + static class GenUnixTimestamp extends FunctionCodeGenerator { + public GenUnixTimestamp() { + super("unix_timestamp"); + } + + @Override + public String nullable() { + return " /**\n" + + " * custom compute nullable.\n" + + " */\n" + + " @Override\n" + + " public boolean nullable() {\n" + + " return arity() > 0;\n" + + " }\n" + + "\n"; + } + } + + static class GenStrToDate extends FunctionCodeGenerator { + public GenStrToDate() { + super("str_to_date"); + } + + @Override + public List imports() { + return ImmutableList.of( + ScalarType.class, + DataType.class, + DateLiteral.class, + Type.class, + StringLikeLiteral.class + ); + } + + @Override + public String computeSignature() { + return " @Override\n" + + " protected FunctionSignature computeSignature(FunctionSignature signature) {\n" + + " /*\n" + + " * The return type of str_to_date depends on whether the time part is included in the format.\n" + + " * If included, it is datetime, otherwise it is date.\n" + + " * If the format parameter is not constant, the return type will be datetime.\n" + + " * The above judgment has been completed in the FE query planning stage,\n" + + " * so here we directly set the value type to the return type set in the query plan.\n" + + " *\n" + + " * For example:\n" + + " * A table with one column k1 varchar, and has 2 lines:\n" + + " * \"%Y-%m-%d\"\n" + + " * \"%Y-%m-%d %H:%i:%s\"\n" + + " * Query:\n" + + " * SELECT str_to_date(\"2020-09-01\", k1) from tbl;\n" + + " * Result will be:\n" + + " * 2020-09-01 00:00:00\n" + + " * 2020-09-01 00:00:00\n" + + " *\n" + + " * Query:\n" + + " * SELECT str_to_date(\"2020-09-01\", \"%Y-%m-%d\");\n" + + " * Return type is DATE\n" + + " *\n" + + " * Query:\n" + + " * SELECT str_to_date(\"2020-09-01\", \"%Y-%m-%d %H:%i:%s\");\n" + + " * Return type is DATETIME\n" + + " */\n" + + " DataType returnType;\n" + + " if (child(1) instanceof StringLikeLiteral) {\n" + + " if (DateLiteral.hasTimePart(((StringLikeLiteral) child(1)).getStringValue())) {\n" + + " returnType = DataType.fromCatalogType(ScalarType.getDefaultDateType(Type.DATETIME));\n" + + " } else {\n" + + " returnType = DataType.fromCatalogType(ScalarType.getDefaultDateType(Type.DATE));\n" + + " }\n" + + " } else {\n" + + " returnType = DataType.fromCatalogType(ScalarType.getDefaultDateType(Type.DATETIME));\n" + + " }\n" + + " return signature.withReturnType(returnType);\n" + + " }\n" + + "\n"; + } + } + + static class GenSubstring extends FunctionCodeGenerator { + public GenSubstring() { + super("substring"); + } + + @Override + public List imports() { + return ImmutableList.of(DataType.class, Optional.class, IntegerLiteral.class); + } + + public String classComment() { + return "// TODO: to be compatible with BE, we set AlwaysNullable here.\n"; + } + + public String methods() { + return " public Expression getSource() {\n" + + " return child(0);\n" + + " }\n" + + "\n" + + " public Expression getPosition() {\n" + + " return child(1);\n" + + " }\n" + + "\n" + + " public Optional getLength() {\n" + + " return arity() == 3 ? Optional.of(child(2)) : Optional.empty();\n" + + " }\n" + + "\n"; + } + + @Override + public String computeSignature() { + return " @Override\n" + + " protected FunctionSignature computeSignature(FunctionSignature signature) {\n" + + " Optional length = getLength();\n" + + " DataType returnType = VarcharType.SYSTEM_DEFAULT;\n" + + " if (length.isPresent() && length.get() instanceof IntegerLiteral) {\n" + + " returnType = VarcharType.createVarcharType(((IntegerLiteral) length.get()).getValue());\n" + + " }\n" + + " return signature.withReturnType(returnType);\n" + + " }\n" + + "\n"; + } + } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rewrite/TypeCoercionTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rewrite/TypeCoercionTest.java index 8427d46cae..5d0196e19f 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rewrite/TypeCoercionTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rewrite/TypeCoercionTest.java @@ -40,6 +40,7 @@ import org.apache.doris.nereids.trees.expressions.literal.Literal; import org.apache.doris.nereids.trees.expressions.literal.SmallIntLiteral; import org.apache.doris.nereids.trees.expressions.literal.StringLiteral; import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; +import org.apache.doris.nereids.types.DateV2Type; import org.apache.doris.nereids.types.DecimalType; import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; @@ -90,8 +91,9 @@ public class TypeCoercionTest { @Test public void testYearImplicitCast() { + // date to datev2 Expression expression = new Year(new DateLiteral("2022-01-01")); - Expression expected = new Year(new DateLiteral("2022-01-01")); + Expression expected = new Year(new Cast(new DateLiteral("2022-01-01"), DateV2Type.INSTANCE)); assertRewrite(expected, expression); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java index d92d6efb4e..2f3e5303fb 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java @@ -22,6 +22,7 @@ import org.apache.doris.nereids.trees.expressions.Add; import org.apache.doris.nereids.trees.expressions.Alias; import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.NamedExpression; +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.functions.agg.Sum; import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral; @@ -74,7 +75,7 @@ public class AggregateDisassembleTest implements PatternMatchSupported { Plan root = new LogicalAggregate<>(groupExpressionList, outputExpressionList, rStudent); Expression localOutput0 = rStudent.getOutput().get(2).toSlot(); - Expression localOutput1 = new Sum(rStudent.getOutput().get(0).toSlot()); + Sum localOutput1 = new Sum(rStudent.getOutput().get(0).toSlot()); Expression localGroupBy = rStudent.getOutput().get(2).toSlot(); PlanChecker.from(MemoTestUtils.createConnectContext(), root) @@ -86,15 +87,16 @@ public class AggregateDisassembleTest implements PatternMatchSupported { .when(agg -> agg.getAggPhase().equals(AggPhase.LOCAL)) .when(agg -> agg.getOutputExpressions().size() == 2) .when(agg -> agg.getOutputExpressions().get(0).equals(localOutput0)) - .when(agg -> agg.getOutputExpressions().get(1).child(0).equals(localOutput1)) + .when(agg -> agg.getOutputExpressions().get(1).child(0) + .children().equals(localOutput1.children())) .when(agg -> agg.getGroupByExpressions().size() == 1) .when(agg -> agg.getGroupByExpressions().get(0).equals(localGroupBy)) ).when(agg -> agg.getAggPhase().equals(AggPhase.GLOBAL)) .when(agg -> agg.getOutputExpressions().size() == 2) .when(agg -> agg.getOutputExpressions().get(0) .equals(agg.child().getOutputExpressions().get(0).toSlot())) - .when(agg -> agg.getOutputExpressions().get(1).child(0) - .equals(new Sum(agg.child().getOutputExpressions().get(1).toSlot()))) + .when(agg -> agg.getOutputExpressions().get(1).child(0).child(0) + .equals(agg.child().getOutputExpressions().get(1).toSlot())) .when(agg -> agg.getGroupByExpressions().size() == 1) .when(agg -> agg.getGroupByExpressions().get(0) .equals(agg.child().getOutputExpressions().get(0).toSlot())) @@ -124,7 +126,7 @@ public class AggregateDisassembleTest implements PatternMatchSupported { new Alias(new Sum(rStudent.getOutput().get(0)), "sum")); Plan root = new LogicalAggregate<>(groupExpressionList, outputExpressionList, rStudent); - Expression localOutput0 = new Sum(rStudent.getOutput().get(0).toSlot()); + Sum localOutput0 = new Sum(rStudent.getOutput().get(0).toSlot()); PlanChecker.from(MemoTestUtils.createConnectContext(), root) .applyTopDown(new AggregateDisassemble()) @@ -134,13 +136,14 @@ public class AggregateDisassembleTest implements PatternMatchSupported { logicalAggregate() .when(agg -> agg.getAggPhase().equals(AggPhase.LOCAL)) .when(agg -> agg.getOutputExpressions().size() == 1) - .when(agg -> agg.getOutputExpressions().get(0).child(0).equals(localOutput0)) + .when(agg -> agg.getOutputExpressions().get(0).child(0).child(0) + .equals(localOutput0.child())) .when(agg -> agg.getGroupByExpressions().size() == 0) ).when(agg -> agg.getAggPhase().equals(AggPhase.GLOBAL)) .when(agg -> agg.getOutputExpressions().size() == 1) .when(agg -> agg.getOutputExpressions().get(0) instanceof Alias) - .when(agg -> agg.getOutputExpressions().get(0).child(0) - .equals(new Sum(agg.child().getOutputExpressions().get(0).toSlot()))) + .when(agg -> agg.getOutputExpressions().get(0).child(0).child(0) + .equals(agg.child().getOutputExpressions().get(0).toSlot())) .when(agg -> agg.getGroupByExpressions().size() == 0) // check id: .when(agg -> agg.getOutputExpressions().get(0).getExprId() @@ -168,7 +171,7 @@ public class AggregateDisassembleTest implements PatternMatchSupported { Plan root = new LogicalAggregate<>(groupExpressionList, outputExpressionList, rStudent); Expression localOutput0 = rStudent.getOutput().get(2).toSlot(); - Expression localOutput1 = new Sum(rStudent.getOutput().get(0).toSlot()); + Sum localOutput1 = new Sum(rStudent.getOutput().get(0).toSlot()); Expression localGroupBy = rStudent.getOutput().get(2).toSlot(); PlanChecker.from(MemoTestUtils.createConnectContext(), root) @@ -180,14 +183,15 @@ public class AggregateDisassembleTest implements PatternMatchSupported { .when(agg -> agg.getAggPhase().equals(AggPhase.LOCAL)) .when(agg -> agg.getOutputExpressions().size() == 2) .when(agg -> agg.getOutputExpressions().get(0).equals(localOutput0)) - .when(agg -> agg.getOutputExpressions().get(1).child(0).equals(localOutput1)) + .when(agg -> agg.getOutputExpressions().get(1).child(0).child(0) + .equals(localOutput1.child())) .when(agg -> agg.getGroupByExpressions().size() == 1) .when(agg -> agg.getGroupByExpressions().get(0).equals(localGroupBy)) ).when(agg -> agg.getAggPhase().equals(AggPhase.GLOBAL)) .when(agg -> agg.getOutputExpressions().size() == 1) .when(agg -> agg.getOutputExpressions().get(0) instanceof Alias) - .when(agg -> agg.getOutputExpressions().get(0).child(0) - .equals(new Sum(agg.child().getOutputExpressions().get(1).toSlot()))) + .when(agg -> agg.getOutputExpressions().get(0).child(0).child(0) + .equals(agg.child().getOutputExpressions().get(1).toSlot())) .when(agg -> agg.getGroupByExpressions().size() == 1) .when(agg -> agg.getGroupByExpressions().get(0) .equals(agg.child().getOutputExpressions().get(0).toSlot())) @@ -213,7 +217,7 @@ public class AggregateDisassembleTest implements PatternMatchSupported { public void distinctAggregateWithGroupBy() { List groupExpressionList = Lists.newArrayList(rStudent.getOutput().get(0).toSlot()); List outputExpressionList = Lists.newArrayList(new Alias( - new Add(new Count(rStudent.getOutput().get(2).toSlot(), true), + new Add(new Count(AggregateParam.distinctAndGlobal(), rStudent.getOutput().get(2).toSlot()), new IntegerLiteral(2)), "c")); Plan root = new LogicalAggregate<>(groupExpressionList, outputExpressionList, rStudent); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/ExpressionEstimationTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/ExpressionEstimationTest.java index 0f61a48309..2f6feabdfc 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/ExpressionEstimationTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/ExpressionEstimationTest.java @@ -60,8 +60,8 @@ class ExpressionEstimationTest { Map slotToColumnStat = new HashMap<>(); slotToColumnStat.put(a, new ColumnStat(500, 4, 4, 0, 0, 500)); StatsDeriveResult stat = new StatsDeriveResult(1000, slotToColumnStat); - Min max = new Min(a); - ColumnStat estimated = ExpressionEstimation.estimate(max, stat); + Min min = new Min(a); + ColumnStat estimated = ExpressionEstimation.estimate(min, stat); Assertions.assertEquals(0, estimated.getMaxValue()); Assertions.assertEquals(1, estimated.getNdv()); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/ExpressionEqualsTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/ExpressionEqualsTest.java index f66071ffa5..dd8ea662d0 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/ExpressionEqualsTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/ExpressionEqualsTest.java @@ -20,6 +20,7 @@ package org.apache.doris.nereids.trees.expressions; import org.apache.doris.nereids.analyzer.UnboundAlias; import org.apache.doris.nereids.analyzer.UnboundFunction; import org.apache.doris.nereids.analyzer.UnboundStar; +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.functions.agg.Sum; import org.apache.doris.nereids.types.IntegerType; @@ -176,14 +177,14 @@ public class ExpressionEqualsTest { Assertions.assertEquals(count1, count2); Assertions.assertEquals(count1.hashCode(), count2.hashCode()); - Count count3 = new Count(child1, true); - Count count4 = new Count(child2, true); + Count count3 = new Count(AggregateParam.distinctAndGlobal(), child1); + Count count4 = new Count(AggregateParam.distinctAndGlobal(), child2); Assertions.assertEquals(count3, count4); Assertions.assertEquals(count3.hashCode(), count4.hashCode()); // bad case - Count count5 = new Count(child1, true); - Count count6 = new Count(child2, false); + Count count5 = new Count(AggregateParam.distinctAndGlobal(), child1); + Count count6 = new Count(child2); Assertions.assertNotEquals(count5, count6); Assertions.assertNotEquals(count5.hashCode(), count6.hashCode()); } diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/RegressionTest.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/RegressionTest.groovy index b5f4de9286..7c45cac9a6 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/RegressionTest.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/RegressionTest.groovy @@ -298,12 +298,12 @@ class RegressionTest { if (!pluginPath.exists() || !pluginPath.isDirectory()) { return } - pluginPath.eachFileRecurse { it -> + pluginPath.eachFileRecurse({ it -> if (it.name.endsWith(".groovy")) { ScriptContext context = new ScriptContext(it, suiteExecutors, actionExecutors, config, [], { name -> true }) File pluginFile = it - context.start { + context.start({ try { SuiteScript pluginScript = new GroovyFileSource(pluginFile).toScript(context, shell) log.info("Begin to load plugin: ${pluginFile.getCanonicalPath()}") @@ -312,9 +312,9 @@ class RegressionTest { } catch (Throwable t) { log.error("Load plugin failed: ${pluginFile.getCanonicalPath()}", t) } - } + }) } - } + }) } static void printPassed() { diff --git a/regression-test/suites/nereids_syntax_p0/one_row_relation.groovy b/regression-test/suites/nereids_syntax_p0/one_row_relation.groovy index ace60c735d..fa9cd58ee7 100644 --- a/regression-test/suites/nereids_syntax_p0/one_row_relation.groovy +++ b/regression-test/suites/nereids_syntax_p0/one_row_relation.groovy @@ -22,7 +22,14 @@ suite("one_row_relation") { sql "SET enable_fallback_to_original_planner=false" test { - sql "select 100, 'abc', substring('abc', 1, 2), substring(substring('abcdefg', 4, 3), 1, 2)" - result([[100, "abc", "ab", "de"]]) + sql "select 100, 'abc', substring('abc', 1, 2), substring(substring('abcdefg', 4, 3), 1, 2), null" + result([[100, "abc", "ab", "de", null]]) + } + + test { + sql """select * from ( + select 100, 'abc', substring('abc', 1, 2), substring(substring('abcdefg', 4, 3), 1, 2), null + )a""" + result([[100, "abc", "ab", "de", null]]) } }