Stellar Language Quick Reference
Also available as:
PDF

Stellar Language Lambda Expressions

Stellar provides the capability to pass lambda expressions to functions which wish to support that layer of indirection.

  • (named_variables) -> stellar_expression : Lambda expression with named variables

    For instance, the lambda expression which calls TO_UPPER on a named argument x could be expressed as (x) -> TO_UPPER(x).

  • var -> stellar_expression : Lambda expression with a single named variable, var

    • For instance, the lambda expression which calls TO_UPPER on a named argument x could be expressed as x -> TO_UPPER(x). Note, this is more succinct but equivalent to the example directly above.

  • () -> stellar_expression : Lambda expression with no named variables.

    • If no named variables are needed, you may omit the named variable section. For instance, the lambda expression which returns a constant false would be () -> false

where

  • named_variables is a comma separated list of variables to use in the Stellar expression

  • stellar_expression is an arbitrary stellar expression

In the core language functions, we support basic functional programming primitives such as

  • MAP - Applies a lambda expression over a list of input. For instance MAP([ 'foo', 'bar'], (x) -> TO_UPPER(x) ) returns [ 'FOO', 'BAR' ]

  • FILTER - Filters a list by a predicate in the form of a lambda expression. For instance FILTER([ 'foo', 'bar'], (x ) -> x == 'foo' ) returns [ 'foo' ]

  • REDUCE - Applies a function over a list of input. For instance REDUCE([ 1, 2, 3], (sum, x) -> sum + x, 0 ) returns 6

Important
Important

Any property that is managed by Ambari should only be modified via Ambari. Otherwise, when you restart a service, Ambari might overwrite your updates. For more information, see Update Properties.