Interface ExpressionRealizer
Produces realized (and evaluation-ready) expressions from an AST and an input type as scope. This interface will eventually be used by pipelines when realizing their parameters against input data.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumStandard set of problem codes for describing problems during expression realization -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ProblemCodeProblem code for when a member is missing from the scope of an expression - used by realizeConstant -
Method Summary
Modifier and TypeMethodDescriptionasStruct(RealizationContext context, RealizedExpression expression) static StringgetImplicitName(RealizationContext context, RealizedExpression realized, Collection<String> used) Return a name we can use to represent the given realized expression in a struct where no member name has been given.static StringgetImplicitTypeName(RealizationContext context, Type type) static StringmakeUnique(String identifier, Collection<String> used) Convenience method for parsing an rl expression in to anExpressionast.realize(Type inputType, Expression expression) realizeAggregate(Type inputType, Expression expression) default ResultOrProblems<RealizedExpression>realizeConstant(Expression expression) Attempts to realize the given expression against an empty struct, returning a meaningful problem if it looks like it failed to realize because it had property access problems (meaning it wasn't constant as it relies on the input scope)
-
Field Details
-
NO_SUCH_MEMBER
Problem code for when a member is missing from the scope of an expression - used by realizeConstant
-
-
Method Details
-
getImplicitTypeName
- Returns:
- a succinct and descriptive name for the given type for use with getImplicitName
-
getImplicitName
static String getImplicitName(RealizationContext context, RealizedExpression realized, Collection<String> used) Return a name we can use to represent the given realized expression in a struct where no member name has been given.
## Examples:
{ # literals 1, # as integer, 2.0, # as floating, 'three', # as text,
# member access foo, # as foo, foo.bar, # as bar # function calls str(foo), # as str_foo if_then_else(a, b, c), # as if_then_else lookup(foo, bookmark('bar')).event_id # as event_id} ```
- Parameters:
used- the names that have already been assigned. If the implicit name would happen to collide with one of these then a counter style suffix is appended to the name to make it distinct, e.g.{foo, foo, foo}is equivalent to{foo: foo, foo_2: foo, foo_3: foo}
-
makeUnique
- Returns:
- a new identifier based on the given one that is unique among
used- will append a_2,_3to the given identifier until it finds one that is not in used.
-
realizeConstant
Attempts to realize the given expression against an empty struct, returning a meaningful problem if it looks like it failed to realize because it had property access problems (meaning it wasn't constant as it relies on the input scope)
- Returns:
- a
RealizedExpressionthat is constant, i.e should succeed when called likeexpr.evaluate(Tuple.EMPTY_TUPLE)and should always return the same result.
-
realize
-
realize
-
realizeAggregate
ResultOrProblems<RealizedAggregateExpression> realizeAggregate(Type inputType, Expression expression) - Returns:
- a
RealizedAggregateExpressionthat can aggregate rows of the given input type.
-
parse
Convenience method for parsing an rl expression in to an
Expressionast.- Parameters:
unparsedExpression- the string of rl to parse- Returns:
- the parsed
Expression
-
asStruct
Convert a realized expression to one that always returns a
Tupleand has return type that is aStruct. Note that this is a simpler routine than type coercion, and is offered to simplify user input cases where a pipeline wants a struct, but the user doesn't need to know or care about this, e.g.select(foo)is simpler thanselect({foo})but they do exactly the same thing.
-