For AI agents: an index of this documentation is at https://developer.rippling.com/llms.txt. Public pages have a Markdown version at the same URL with .md added.

Skip to main content
index

LATERAL FLATTEN() Function

Use with AI:Rippling AI ChatGPT Claude Cursor

Description​

Unnests the ARRAY and JSON Object into individual rows

Syntax​

LATERAL FLATTEN(expression, path, outer, recursive, mode)

Parameters​

ParameterDescriptionRequired
expressionThe column or expression with a VARIANT, OBJECT, or ARRAY to flattenYes
pathJSONPath-like string specifying the path within the input to flatten (e.g. '$.items').No
outerBoolean; if TRUE, returns a row with NULL if the input is empty or NULL; Default is FALSENo
recursiveBoolean; if TRUE, flattens nested structures recursively. Default is FALSENo
modeString; can be 'object' or 'array'; Determines how input is flattened; Typically inferred automaticallyNo

Notes​

  • JSON arrays need to be casted to ARRAY(JSON) before they can be flattened

Example​

SELECT 
flatten_val.someContrivedValue::VARCHAR, flatten_val.someContrivedKey
FROM
rippling.employee.Employee e
CROSS JOIN
LATERAL FLATTEN(
JSON_PARSE(CONCAT('{"someKey": " ', e.work_email, ' ", "someKey2": " ', e.full_name, ' "}'))
) AS flatten_val(someContrivedKey, someContrivedValue);