Evaluates an expression to perform arithmetic or logical calculations or string operations.
On change of input values (once all in-use inputs have been received), the expression specified in the parameter is re-calculated.
The expression language is much like EPL (see
EPL reference), but is restricted to
float,
integer,
string and
boolean types. All numeric literals are treated as
float type values, even if they have no fractional part. Integer values can only be obtained as the result of functions such as
floor(). Similar to EPL,
integer and
float are not implicitly convertible within an expression. If the result of an expression is an
integer value, it is converted to a
float automatically (there might be a loss of precision). Boolean values can be specified using the Boolean literals
true and
false. Boolean literals are case insensitive, so for example,
TRUE and
True are allowed. String values can be specified by enclosing string literals in double quotes, for example "my value". Special characters are encoded with a backslash (
\). The following special characters (along which their encoding) are supported in string literals:
The values of the inputs are available as
input1,
input2,
input3,
input4 and
input5. The input values can be of type
float,
string,
boolean and
any. Logical, relational, numerical and equality operators can be used on the values of the supported types. Logical operators are case insensitive, so for example,
AND and
And are allowed. Built-in methods on the
float,
integer,
string and
boolean types can be called, including
x.abs() (absolute value of
x),
x.pow(y) (raise
x to the power
y),
x.sin() (sine of
x in radians),
x.round() (rounds
x to the nearest integer), and
s.ltrim() (remove whitespace from the start of the string
s). Built-in static methods of the supported types can be called by specifying the type name, followed by a dot (
.) and the method name, for example,
float.max(input1, input2) (find the larger of two input values). Built-in constants on the supported types can be accessed by specifying the type name, followed by a dot (
.) and the constant name, for example,
float.E (Euler's constant). Values of type
any are unpacked at runtime to evaluate the expression. After unpacking, the value must be of type
float,
string or
boolean. The type checker tries to validate the expressions during the validation phase, but this is not always possible with the
any type. So if an expression contains the
any type, even if it passes the validation phase, it can still fail at runtime due to a wrong type of variable being passed or an unsupported operation being performed. For a full list of built-in methods and constants, consult the API
Reference for EPL (ApamaDoc).