Package org.apache.druid.segment.virtual
Class ExpressionSelectors
- java.lang.Object
-
- org.apache.druid.segment.virtual.ExpressionSelectors
-
public class ExpressionSelectors extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancanMapOverDictionary(Expr.BindingAnalysis bindingAnalysis, ColumnCapabilities columnCapabilities)Returns whether an expression can be applied to unique values of a particular column (like those in a dictionary) rather than being applied to each row individually.static ObjectcoerceEvalToObjectOrList(ExprEval eval)CoercesExprEvalvalue back to aColumnType.STRINGselector friendly value, converting into: - the expression value if the value is not an array - the single array element if the value is an array with 1 element - a list with all of the array elements if the value is an array with more than 1 element This method is used bymakeStringColumnValueSelector(ColumnSelectorFactory, Expr), which is used exclusively for makingColumnValueSelectorwhen anExpressionVirtualColumnhas STRING output type, and byExpressionTransformwhich should be reconsidered if we ever want to add support for ingestion transforms producingValueType.ARRAYtyped outputs.static Expr.ObjectBindingcreateBindings(ColumnSelectorFactory columnSelectorFactory, ExpressionPlan plan)CreateExpr.ObjectBindinggiven aColumnSelectorFactoryandExpressionPlanwhich provides the set of identifiers which need a binding (list of required columns), and context of whether or not they are used as array or scalar inputsstatic ColumnValueSelectormakeColumnValueSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression)Makes a ColumnValueSelector whose getObject method returns an Object that is the value computed by anExprEval.static DimensionSelectormakeDimensionSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression, ExtractionFn extractionFn)Makes a single or multi-valueDimensionSelectorwrapper around aColumnValueSelectorcreated bymakeExprEvalSelector(ColumnSelectorFactory, Expr)as appropriatestatic ColumnValueSelector<ExprEval>makeExprEvalSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression)Makes a ColumnValueSelector whose getObject method returns anExprEval.static <T> com.google.common.base.Supplier<T>makeNullableNumericSupplier(ColumnValueSelector selector, com.google.common.base.Supplier<T> supplier)Wraps aColumnValueSelectorand uses it to supply numeric values in a null-aware way.static ColumnValueSelectormakeStringColumnValueSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression)
-
-
-
Method Detail
-
makeColumnValueSelector
public static ColumnValueSelector makeColumnValueSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression)
Makes a ColumnValueSelector whose getObject method returns an Object that is the value computed by anExprEval.
-
makeStringColumnValueSelector
public static ColumnValueSelector makeStringColumnValueSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression)
-
makeExprEvalSelector
public static ColumnValueSelector<ExprEval> makeExprEvalSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression)
Makes a ColumnValueSelector whose getObject method returns anExprEval.
-
makeDimensionSelector
public static DimensionSelector makeDimensionSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression, @Nullable ExtractionFn extractionFn)
Makes a single or multi-valueDimensionSelectorwrapper around aColumnValueSelectorcreated bymakeExprEvalSelector(ColumnSelectorFactory, Expr)as appropriate
-
canMapOverDictionary
public static boolean canMapOverDictionary(Expr.BindingAnalysis bindingAnalysis, @Nullable ColumnCapabilities columnCapabilities)
Returns whether an expression can be applied to unique values of a particular column (like those in a dictionary) rather than being applied to each row individually. This function should only be called if you have already determined that an expression is over a single column, and that single column has a dictionary.- Parameters:
bindingAnalysis- result of callingExpr.analyzeInputs()on an expressioncolumnCapabilities-ColumnCapabilitiesfor the input binding
-
createBindings
public static Expr.ObjectBinding createBindings(ColumnSelectorFactory columnSelectorFactory, ExpressionPlan plan)
CreateExpr.ObjectBindinggiven aColumnSelectorFactoryandExpressionPlanwhich provides the set of identifiers which need a binding (list of required columns), and context of whether or not they are used as array or scalar inputs
-
makeNullableNumericSupplier
public static <T> com.google.common.base.Supplier<T> makeNullableNumericSupplier(ColumnValueSelector selector, com.google.common.base.Supplier<T> supplier)
Wraps aColumnValueSelectorand uses it to supply numeric values in a null-aware way.
-
coerceEvalToObjectOrList
@Nullable public static Object coerceEvalToObjectOrList(ExprEval eval)
CoercesExprEvalvalue back to aColumnType.STRINGselector friendly value, converting into: - the expression value if the value is not an array - the single array element if the value is an array with 1 element - a list with all of the array elements if the value is an array with more than 1 element This method is used bymakeStringColumnValueSelector(ColumnSelectorFactory, Expr), which is used exclusively for makingColumnValueSelectorwhen anExpressionVirtualColumnhas STRING output type, and byExpressionTransformwhich should be reconsidered if we ever want to add support for ingestion transforms producingValueType.ARRAYtyped outputs.
-
-