public class Parser extends Object
| Constructor and Description |
|---|
Parser() |
| Modifier and Type | Method and Description |
|---|---|
static Expr |
applyUnappliedBindings(Expr expr,
Expr.BindingAnalysis bindingAnalysis,
List<String> bindingsToApply)
|
static Expr |
flatten(Expr expr)
|
static Expr |
foldUnappliedBindings(Expr expr,
Expr.BindingAnalysis bindingAnalysis,
List<String> bindingsToApply,
String accumulatorId)
|
static ApplyFunction |
getApplyFunction(String name)
|
static Function |
getFunction(String name)
Get
Function by NamedFunction.name() |
static com.google.common.base.Supplier<Expr> |
lazyParse(String in,
ExprMacroTable macroTable)
Create a memoized lazy supplier to parse a string into a flattened
Expr. |
static Expr |
parse(String in,
ExprMacroTable macroTable)
Parse a string into a flattened
Expr. |
static Expr |
parse(String in,
ExprMacroTable macroTable,
boolean withFlatten) |
static void |
validateExpr(Expr expression,
Expr.BindingAnalysis bindingAnalysis)
Validate that an expression uses input bindings in a type consistent manner.
|
public static Function getFunction(String name)
Function by NamedFunction.name()public static ApplyFunction getApplyFunction(String name)
public static com.google.common.base.Supplier<Expr> lazyParse(@Nullable String in, ExprMacroTable macroTable)
Expr. There is some overhead to this,
and these objects are all immutable, so this assists in the goal of re-using instead of re-creating whenever
possible.
Lazy form of parse(String, ExprMacroTable)in - expression to parsemacroTable - additional extensions to expression languagepublic static Expr parse(String in, ExprMacroTable macroTable)
Expr. There is some overhead to this, and these objects are all immutable,
so re-use instead of re-creating whenever possible.in - expression to parsemacroTable - additional extensions to expression languagepublic static Expr parse(String in, ExprMacroTable macroTable, boolean withFlatten)
public static Expr applyUnappliedBindings(Expr expr, Expr.BindingAnalysis bindingAnalysis, List<String> bindingsToApply)
Expr given a list of known (or uknown) multi-value input columns that are
used in a scalar manner, walking the Expr tree and lifting array variables into the LambdaExpr of
ApplyFunctionExpr and transforming the arguments of FunctionExpr as necessary.
This function applies a transformation for "map" style uses, such as column selectors, where the supplied
expression will be transformed to return an array of results instead of the scalar result (or appropriately
rewritten into existing apply expressions to produce correct results when referenced from a scalar context).
This function and foldUnappliedBindings(Expr, Expr.BindingAnalysis, List, String) exist to handle
"multi-valued" string dimensions, which exist in a superposition of both single and multi-valued during realtime
ingestion, until they are written to a segment and become locked into either single or multi-valued. This also
means that multi-valued-ness can vary for a column from segment to segment, so this family of transformation
functions exist so that multi-valued strings can be expressed in either and array or scalar context, which is
important because the writer of the query might not actually know if the column is definitively always single or
multi-valued (and it might in fact not be).public static Expr foldUnappliedBindings(Expr expr, Expr.BindingAnalysis bindingAnalysis, List<String> bindingsToApply, String accumulatorId)
Expr given a list of known (or uknown) multi-value input columns that are
used in a scalar manner, walking the Expr tree and lifting array variables into the LambdaExpr of
ApplyFunctionExpr and transforming the arguments of FunctionExpr as necessary.
This function applies a transformation for "fold" style uses, such as aggregators, where the supplied
expression will be transformed to accumulate the result of applying the expression to each value of the unapplied
input (or appropriately rewritten into existing apply expressions to produce correct results when referenced from
a scalar context). This rewriting assumes that there exists some accumulator variable, which is re-used as the
accumulator for this fold rewrite, so that evaluating each expression can be accumulated into the larger external
fold operation that an aggregator might be performing.
This function and applyUnappliedBindings(Expr, Expr.BindingAnalysis, List) exist to handle
"multi-valued" string dimensions, which exist in a superposition of both single and multi-valued during realtime
ingestion, until they are written to a segment and become locked into either single or multi-valued. This also
means that multi-valued-ness can vary for a column from segment to segment, so this family of transformation
functions exist so that multi-valued strings can be expressed in either and array or scalar context, which is
important because the writer of the query might not actually know if the column is definitively always single or
multi-valued (and it might in fact not be).public static void validateExpr(Expr expression, Expr.BindingAnalysis bindingAnalysis)
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.