xplenty_rb.transform_bag

Description

Transforms a bag (array) of values into a bag of other values using the lambda expression. The lambda expression must be Ruby compliant.

Syntax

xplenty_rb.transform_bag(bag, lambda_expression)

Arguments

  bag - bag. 

  lambda_expression - string containing a Ruby compliant expression to manipulate the bag prior to concatenation, such as sort or filter. 

Examples

bag1 is [{"id": 2}, {"id": 1}, {"id": 3, "name": "My Name"}]

xplenty_rb.transform_bag(bag1,'|x| x.map { |y| JSON(y)["id"] }') returns the bag [(2),(1),(3)].

* The inner lambda expression is required because the bag actually contains tuples (manifested as arrays) of fields - in this case, arrays of a single element.

Return value datatype

Bag.

Notes

For more information, read How do I process JSON data.

Impact of null value

If input is null, returns null.

If the lambda expression is null or erroneous, the function fails.

Feedback and Knowledge Base