...
What is the PEL?
The Pipeline Expression Language (PEL) or just PE (Pipeline Expression) is an expression language that can optionally be used inside a pipeline to do data mapping and to dynamically calculate, set and change values at processing time of the pipeline. This gives you a huge flexibility in your pipeline.
...
Output:
Operators
The PEL supports all common operators as also known for most programming languages. It is similar to the expressions in Microsoft Excel, although the syntax is slightly different and aligned a bit more with the traditional programming syntax.
Relational operators
Is equal (==)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{2 == 1}" |
Output:
Is not equal (!=)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{2 != 1}" |
Output:
Less than (<)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{1 < 5}" |
Output:
Example 2
Code Block |
---|
pipeline:
- log:
message: "#{0.5 < 1}" |
Output:
Less or equal than (<=)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{1 <= 5}" |
Output:
Greater than (>)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{1 > 5}" |
Output:
Greater or equal than (>=)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{5 >= 5}" |
Output:
Detect alphabetical order with <, >, <=, >=
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{'Adam' < 'Zacharias'}" |
Output:
Regular expression matching (matches)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{'5.0067' matches '^-?\\d+(\\.\\d{2})?$'}" |
Output:
Logical operators
and
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{true and false}" |
Output:
or
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{true or false}" |
Output:
not (!)
Example 1
Code Block |
---|
pipeline:
- log:
message: "#{!true}" |
Output:
Mathematical operators
Addition and subtraction
Example 1 - Addition
Code Block |
---|
pipeline:
- log:
message: "#{1 + 1}" |
Output:
Example 2 - Subtraction
Code Block |
---|
pipeline:
- log:
message: "#{10 - 1}" |
Output:
Example 3 - Addition an subtraction
Code Block |
---|
pipeline:
- log:
message: "#{25 - 5 + 10}" |
Output:
Example 4 - String concatenation
Code Block |
---|
pipeline:
- log:
message: "#{'Hello ' + 'World!'}" |
Output:
Multiplication and division
Example 1 - Multiplication
Code Block |
---|
pipeline:
- log:
message: "#{3 * 5}" |
Output:
Example 2 - Negative multiplication
Code Block |
---|
pipeline:
- log:
message: "#{-1 * 5}" |
Output:
Example 3 - Division
Code Block |
---|
pipeline:
- log:
message: "#{20 / 5}" |
Output:
Example 4 - Modulus
Code Block |
---|
pipeline:
- log:
message: "#{7 % 4}" |
Output:
Example 5 - Operator precedence
Code Block |
---|
pipeline:
- log:
message: "#{5 + 4 - 1 * 2}" |
Output:
Example 6 - Brackets
Code Block |
---|
pipeline:
- log:
message: "#{(5 + 4 - 1) * 2}" |
Output:
Assignment
Example 1
Code Block |
---|
pipeline:
- set:
value: "1"
output: "#{vars.counter}"
- log:
message: "#{vars.counter}" |
Output:
Example 2
Code Block |
---|
vars:
counter: 12
pipeline:
- set:
value: "#{vars.counter + 1}"
output: "#{vars.counter}"
- log:
message: "#{vars.counter}" |
Output:
Working with lists and maps / dictionaries
Creating a new list
Example 1 - A new empty list
Code Block |
---|
vars:
numbers: "#{{}}"
pipeline:
- log:
message: "#{vars.numbers}" |
Output:
Example 2 - A new list with default content
Code Block |
---|
|
vars:
numbers: "#{{1, 2, 4}}"
pipeline:
- log:
message: "#{vars.numbers}" |
Output:
Example 3 - A new, nested list
Code Block |
---|
|
vars:
scores: "#{{ {1, 3}, {5, 8} }}"
pipeline:
- log:
message: "#{vars.scores}" |
...
Code Block |
---|
[[1, 3], [5, 8]] |
Accessing lists and arrays
Example 1
Code Block |
---|
|
vars:
numbers: "#{{1, 2, 4}}"
pipeline:
- log:
message: "#{vars.numbers[1]}" |
Output:
Creating a new map / dictionary
Example 1 - A new empty map
Code Block |
---|
vars:
persons: "#{ {:} }"
pipeline:
- log:
message: "#{vars.persons}" |
Output:
Example 2 - A new map with default values
Code Block |
---|
vars:
persons: "#{ {hanna:'burger', max:'hotdog', julie:'salad'} }"
pipeline:
- log:
message: "#{vars.persons}" |
...
Code Block |
---|
{hanna=burger, max=hotdog, julie=salad} |
Example 3 - A new map with later binding
Code Block |
---|
vars:
persons: "#{ {:} }"
pipeline:
- log:
message: "#{vars.persons['Hanna'] = 23}" |
Output:
Accessing maps/dictionaries
Example 1
Code Block |
---|
vars:
persons: "#{ {hanna:'burger', max:'hotdog', julie:'salad'} }"
pipeline:
- log:
message: "#{vars.persons['max']}" |
Output:
Navigating objects
A PE can point to values inside an object (or nested data structure), like this JSON for example:
...
Code Block |
---|
#{person.hobbies[0]} |
Example 1
In this more advanced example, there are different things to mention:
...
Code Block |
---|
Name: Bart Simpson
Age: 12
Hobby: skateboard |
Selection Expression
With the selection syntax you can select a subset of items from a given collection to be returned as new collection by specifying a selection expression.
...
Whereas collectionName
is the variable name of the collection (can be an array, map, list, aso.) and selectionExpression
is the expression which selects the items to be returned from the list.
Example 1
Lets assume we have a collection of entities like this stored in the body:
...
Code Block |
---|
vars:
data: '#{{
{
person: {
name: "Bart Simpson",
age: 12,
hobbies: {
"skateboard",
"tv",
"pranks"
}
}
},
{
person: {
name: "Maggie Simpson",
age: 1,
hobbies: {
"drinking milk",
"crawling",
"crying"
}
}
}
}}'
pipeline:
- log:
message: "#{vars.data.?[person.name == 'Maggie Simpson']}" |
Projection Expression
With the projection syntax you can select specific property values out from a collection of objects.
...
Whereas collectionName
is the variable name of the collection (can be an array, map, list, aso.) and projectionExpression
is the expression which selects the properties to be returned from each object in the list.
Example 1
Lets assume we have a collection of entities like this stored in the body:
...
Code Block |
---|
vars:
data: '#{{
{
person: {
name: "Bart Simpson",
age: 12,
hobbies: {
"skateboard",
"tv",
"pranks"
}
}
},
{
person: {
name: "Maggie Simpson",
age: 1,
hobbies: {
"drinking milk",
"crawling",
"crying"
}
}
}
}}'
pipeline:
- log:
message: "#{vars.data.![person.name]}" |
PEL Utils
Inside a PE you can use built-in Utils as helpers to simplify work.
A refecerence about available PEL Utils can be found in this section: PEL Utils Reference.
Example 1
Code Block |
---|
vars:
cities: "Munich, Bratislava, New York"
pipeline:
- log:
message: "#{@list.size(vars.cities)}" |
Output:
Example 2
Code Block |
---|
pipeline:
- log:
message: "#{@text.lang('Hallo, Herr Meier!')}" |
...