Flatten

Description

Flatten removes a level of nesting in a record. The result of applying Flatten to a bag is that each item in the bag will appear in a record of its own. If you flatten two bags in the same data set, they will be crossed join (i.e. you will get records for each item in the first bag with each of the items in the second bag).

Syntax

Flatten(bag)

Examples

TOKENIZE('a,b,c',',') returns a bag with 3 items: {(a),(b),(c)}

Flatten(TOKENIZE('a,b,c',',')) returns 3 records:

a
b
c

Notes

Since Flatten works at the record level rather than the field level, it can't be used in the x-console.

Return value datatype

Depends on input datatype.

Impact of null value

If input is null, returns null.

Feedback and Knowledge Base