Package org.apache.druid.math.expr
Interface Function
- All Superinterfaces:
NamedFunction
- All Known Implementing Classes:
Function.Abs,Function.Acos,Function.ArrayAddElementFunction,Function.ArrayAppendFunction,Function.ArrayConcatFunction,Function.ArrayConstructorFunction,Function.ArrayContainsFunction,Function.ArrayLengthFunction,Function.ArrayOffsetFunction,Function.ArrayOffsetOfFunction,Function.ArrayOrdinalFunction,Function.ArrayOrdinalOfFunction,Function.ArrayOverlapFunction,Function.ArrayPrependFunction,Function.ArrayScalarFunction,Function.ArraySetAddAllFunction,Function.ArraySetAddFunction,Function.ArraysFunction,Function.ArraySliceFunction,Function.ArraysMergeFunction,Function.ArrayToMultiValueStringFunction,Function.ArrayToStringFunction,Function.Asin,Function.Atan,Function.Atan2,Function.BitwiseAnd,Function.BitwiseComplement,Function.BitwiseConvertDoubleToLongBits,Function.BitwiseConvertLongBitsToDouble,Function.BitwiseOr,Function.BitwiseShiftLeft,Function.BitwiseShiftRight,Function.BitwiseXor,Function.BivariateBitwiseMathFunction,Function.BivariateFunction,Function.BivariateMathFunction,Function.CaseSearchedFunc,Function.CaseSimpleFunc,Function.CastFunc,Function.Cbrt,Function.Ceil,Function.CoalesceFunc,Function.ConcatFunc,Function.ConditionFunc,Function.CopySign,Function.Cos,Function.Cosh,Function.Cot,Function.Div,Function.DoubleBivariateMathFunction,Function.DoubleUnivariateMathFunction,Function.Exp,Function.Expm1,Function.Floor,Function.GetExponent,Function.GreatestFunc,Function.HumanReadableBinaryByteFormatFunc,Function.HumanReadableDecimalByteFormatFunc,Function.HumanReadableDecimalFormatFunc,Function.Hypot,Function.IsDistinctFromFunc,Function.IsFalseFunc,Function.IsNotDistinctFromFunc,Function.IsNotFalseFunc,Function.IsNotNullFunc,Function.IsNotTrueFunc,Function.IsNullFunc,Function.IsTrueFunc,Function.LeastFunc,Function.LeftFunc,Function.Log,Function.Log10,Function.Log1p,Function.LowerFunc,Function.LpadFunc,Function.Max,Function.Min,Function.MultiValueStringHarmonizeNullsFunction,Function.MultiValueStringToArrayFunction,Function.MvContainsFunction,Function.MvOverlapFunction,Function.NextAfter,Function.NextUp,Function.NvlFunc,Function.ParseLong,Function.Pi,Function.Pow,Function.ReduceFunction,Function.Remainder,Function.RepeatFunc,Function.ReplaceFunc,Function.ReverseFunc,Function.RightFunc,Function.Rint,Function.Round,Function.RpadFunc,Function.SafeDivide,Function.ScalarInArrayFunction,Function.Scalb,Function.Signum,Function.Sin,Function.Sinh,Function.SizeFormatFunc,Function.Sqrt,Function.StringFormatFunc,Function.StringLongFunction,Function.StringToArrayFunction,Function.StrlenFunc,Function.StrposFunc,Function.SubMonthFunc,Function.SubstringFunc,Function.Tan,Function.Tanh,Function.TimestampFromEpochFunc,Function.ToDegrees,Function.ToRadians,Function.Ulp,Function.UnivariateFunction,Function.UnivariateMathFunction,Function.UnixTimestampFunc,Function.UpperFunc
Base interface describing the mechanism used to evaluate a
FunctionExpr. All Function implementations
are immutable.
Do NOT remove "unused" members in this class. They are used by generated Antlr-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classstatic classScaffolding for a 2 argumentFunctionwhich accepts one array and one scalar input and adds the scalar input to the array in some way.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classFunctionthat takes 1 array operand and 1 scalar operandstatic classstatic classstatic classFunctionthat takes 2 array operandsstatic classstatic classBase scaffolding for functions which accept 2 array arguments and combine them in some waystatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classBase class for a 2 variable inputFunctionimplementationstatic classBase class for a 2 variable input mathematicalFunction, with specialized 'eval' implementations that operate on primitive number typesstatic class"Searched CASE" function, similar toCASE WHEN boolean_expr THEN result [ELSE else_result] ENDin SQL.static class"Simple CASE" function, similar toCASE expr WHEN value THEN result [ELSE else_result] ENDin SQL.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classMany math functions always output aDoubleprimitive, regardless of input type.static classMany math functions always output aDoubleprimitive, regardless of input type.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classSQL function "x IS DISTINCT FROM y".static classSQL function "IS FALSE".static classSQL function "x IS NOT DISTINCT FROM y".static classSQL function "IS NOT FALSE".static classstatic classSQL function "IS NOT TRUE".static classstatic classSQL function "IS TRUE".static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classPrimarily internal helper function used to coerce null, [], and [null] into [null], similar to the logic done byExpressionSelectors.supplierFromDimensionSelector(org.apache.druid.segment.DimensionSelector, boolean, boolean)when the 3rd argument is true, which is done when implicitly mapping scalar functions over mvd values.static classstatic classstatic classstatic classstatic classstatic classnvl is like coalesce, but accepts exactly two arguments.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classBase class for a 2 variable inputFunctionwhose first argument is aExprType.STRINGand second argument isExprType.LONG.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classBase class for a single variable inputFunctionimplementationstatic classBase class for a single variable input mathematicalFunction, with specialized 'eval' implementations that that operate on primitive number typesstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionapply(List<Expr> args, Expr.ObjectBinding bindings) Evaluate the function, given a list of arguments and a set of bindings to provide values forIdentifierExpr.default BitmapColumnIndexasBitmapColumnIndex(ColumnIndexSelector selector, List<Expr> args) Allows aFunctionto be computed into aBitmapColumnIndex.default ColumnIndexSupplierasColumnIndexSupplier(ColumnIndexSelector selector, ColumnType outputType, List<Expr> args) Allows aFunctionto provide anColumnIndexSuppliergiven access to the underlyingColumnIndexSupplierandColumnHolderof the base table.default FunctionasSingleThreaded(List<Expr> args, Expr.InputBindingInspector inspector) default <T> ExprVectorProcessor<T>asVectorProcessor(Expr.VectorInputBindingInspector inspector, List<Expr> args) Builds a 'vectorized' function expression processor, that can build vectorized processors for its input values usingExpr.asVectorProcessor(org.apache.druid.math.expr.Expr.VectorInputBindingInspector), for use in vectorized query engines.default booleancanVectorize(Expr.InputBindingInspector inspector, List<Expr> args) Check if a function can be 'vectorized', for a given set ofExprinputs.getArrayInputs(List<Expr> args) Given a list of arguments to thisFunction, get the set of arguments that must evaluate to an array valuegetOutputType(Expr.InputBindingInspector inspector, List<Expr> args) Compute the output type of this function for a given set of argument expression inputs.getScalarInputs(List<Expr> args) Given a list of arguments to thisFunction, get the set of arguments that must evaluate to a scalar valuedefault booleanReturns true if a function expects any array argumentsdefault booleanReturns true if function produces an array.voidvalidateArguments(List<Expr> args) Validate function arguments.Methods inherited from interface org.apache.druid.math.expr.NamedFunction
name, processingFailed, processingFailed, validationFailed, validationFailed, validationHelperCheckAnyOfArgumentCount, validationHelperCheckArgIsLiteral, validationHelperCheckArgumentCount, validationHelperCheckArgumentCount, validationHelperCheckArgumentRange, validationHelperCheckLambaArgumentCount, validationHelperCheckMinArgumentCount, validationHelperCheckMinArgumentCount
-
Method Details
-
asSingleThreaded
-
apply
Evaluate the function, given a list of arguments and a set of bindings to provide values forIdentifierExpr. -
getScalarInputs
Given a list of arguments to thisFunction, get the set of arguments that must evaluate to a scalar value -
getArrayInputs
Given a list of arguments to thisFunction, get the set of arguments that must evaluate to an array value -
hasArrayInputs
default boolean hasArrayInputs()Returns true if a function expects any array arguments -
hasArrayOutput
default boolean hasArrayOutput()Returns true if function produces an array. AllFunctionimplementations are expected to exclusively produce either scalar or array values. -
validateArguments
Validate function arguments. This method is called whenever aFunctionExpris created, and should validate everything that is feasible up front. Note that input type information is typically unavailable at the timeExprare parsed, and so this method is incapable of performing complete validation. -
getOutputType
Compute the output type of this function for a given set of argument expression inputs. -
canVectorize
Check if a function can be 'vectorized', for a given set ofExprinputs. If this method returns true,asVectorProcessor(org.apache.druid.math.expr.Expr.VectorInputBindingInspector, java.util.List<org.apache.druid.math.expr.Expr>)is expected to produce aExprVectorProcessorwhich can evaluate values in batches to use with vectorized query engines. -
asVectorProcessor
default <T> ExprVectorProcessor<T> asVectorProcessor(Expr.VectorInputBindingInspector inspector, List<Expr> args) Builds a 'vectorized' function expression processor, that can build vectorized processors for its input values usingExpr.asVectorProcessor(org.apache.druid.math.expr.Expr.VectorInputBindingInspector), for use in vectorized query engines. -
asColumnIndexSupplier
@Nullable default ColumnIndexSupplier asColumnIndexSupplier(ColumnIndexSelector selector, @Nullable ColumnType outputType, List<Expr> args) Allows aFunctionto provide anColumnIndexSuppliergiven access to the underlyingColumnIndexSupplierandColumnHolderof the base table. Unlike the contracts of other index supplier methods, a null return value for this method is not indicative of anything other than theFunctionimplementation having no specialized index supplier implementation, and so callers can fall back to generic handling as appropriate. -
asBitmapColumnIndex
@Nullable default BitmapColumnIndex asBitmapColumnIndex(ColumnIndexSelector selector, List<Expr> args) Allows aFunctionto be computed into aBitmapColumnIndex. The suppliedColumnIndexSelectorprovides access to underlyingColumnIndexSupplierand evenColumnHolder. Coupled withasColumnIndexSupplier(ColumnIndexSelector, ColumnType, List<Expr>), which allowsFunctionto provide indexes of their own, it allows for a system of composing indexes on top of any base column structures. UnlikeExpr.asBitmapColumnIndex(ColumnIndexSelector), a null return value of this method is not indicative of anything other than theFunctionimplementation not having a specialized way to compute into aBitmapColumnIndex, and so callers can fall back to generic handling as appropriate.
-