|
GRELControls
Controls supported by the Google Refine Expression Language (GREL)
There are inline controls to support branching and essentially looping. They look like functions, but unlike functions, their arguments don't all get evaluated down to value before they get run. A control can decide which part of the code to execute and can affect the environment bindings. Functions, on the other hand, can't do either. Each control decides which of their arguments to evaluate to value, and how. if(expression o, expression eTrue, expression eFalse)Expression o is evaluated to a value. If that value is true, then expression eTrue is evaluated and the result is the value of the whole if expression. Examples:
with(expression o, variable v, expression e)Evaluates expression o and binds its value to variable name v. Then evaluates expression e and returns that result.
filter(expression a, variable v, expression test)Evaluates expression a to an array. Then for each array element, binds its value to variable name v, evaluates expression test which should return a boolean. If the boolean is true, pushes v onto the result array.
forEach(expression a, variable v, expression e)Evaluates expression a to an array. Then for each array element, binds its value to variable name v, evaluates expression e, and pushes the result onto the result array.
forEachIndex(expression a, variable i, variable v, expression e)Evaluates expression a to an array. Then for each array element, binds its index to variable i and its value to variable name v, evaluates expression e, and pushes the result onto the result array.
forRange(number from, number to, number step, variable v, expression e)Iterates over the variable v starting at from, incrementing by step each time while less than to. At each iteration, evaluates expression e, and pushes the result onto the result array. forNonBlank(expression o, variable v, expression eNonBlank, expression eBlank)Evaluates expression o. If it is non-blank, binds its value to variable name v, evaluates expression eNonBlank and returns the result. Otherwise (if o evaluates to blank), evaluates expression eBlank and returns that result instead. isBlank, isNonBlank, isNull, isNotNull, isNumeric, isErrorisX(e) : evaluates expression e and returns whether its value is X. Examples:
| |||||||||||||||||||||||||||||||||||||||||||