Custom Evaluation - VladimirSiv/pytransflow GitHub Wiki
Evaluation of conditions in pytransflow is done using simpleeval library. This library allows us to extend the list of available evaluation functions.
Functions
For example, we can define our custom() function and use it in condition
expressions
from pytransflow.core import Flow, SimpleEval
def custom():
...
SimpleEval.add_function(
name="custom",
function=custom
)
records = [...]
flow = Flow(name="test")
flow.process(records)
and then use it in a transformation
transformations:
- add_field:
name: b
value: 1
condition: "custom(@a/b/c) == 'A'"
Note:
simpleevalcomes with a built-in set of functions, if you define the same function name, the built-in function will be overridden in runtime