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 boolean
canMapOverDictionary(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 Object
coerceEvalToObjectOrList(ExprEval eval)
CoercesExprEval
value back to aColumnType.STRING
selector 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 makingColumnValueSelector
when anExpressionVirtualColumn
has STRING output type, and byExpressionTransform
which should be reconsidered if we ever want to add support for ingestion transforms producingValueType.ARRAY
typed outputs.static Expr.ObjectBinding
createBindings(ColumnSelectorFactory columnSelectorFactory, ExpressionPlan plan)
CreateExpr.ObjectBinding
given aColumnSelectorFactory
andExpressionPlan
which 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 ColumnValueSelector
makeColumnValueSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression)
Makes a ColumnValueSelector whose getObject method returns an Object that is the value computed by anExprEval
.static DimensionSelector
makeDimensionSelector(ColumnSelectorFactory columnSelectorFactory, Expr expression, ExtractionFn extractionFn)
Makes a single or multi-valueDimensionSelector
wrapper around aColumnValueSelector
created 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 aColumnValueSelector
and uses it to supply numeric values in a null-aware way.static ColumnValueSelector
makeStringColumnValueSelector(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-valueDimensionSelector
wrapper around aColumnValueSelector
created 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
-ColumnCapabilities
for the input binding
-
createBindings
public static Expr.ObjectBinding createBindings(ColumnSelectorFactory columnSelectorFactory, ExpressionPlan plan)
CreateExpr.ObjectBinding
given aColumnSelectorFactory
andExpressionPlan
which 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 aColumnValueSelector
and uses it to supply numeric values in a null-aware way.
-
coerceEvalToObjectOrList
@Nullable public static Object coerceEvalToObjectOrList(ExprEval eval)
CoercesExprEval
value back to aColumnType.STRING
selector 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 makingColumnValueSelector
when anExpressionVirtualColumn
has STRING output type, and byExpressionTransform
which should be reconsidered if we ever want to add support for ingestion transforms producingValueType.ARRAY
typed outputs.
-
-