thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

FLATTEN Function

A Snowflake table function that explodes arrays or objects in VARIANT columns into one row per element.

Definition

FLATTEN is used with LATERAL to join each parent row to its nested elements and returns columns such as VALUE, KEY, INDEX and PATH. RECURSIVE => TRUE flattens nested structures fully.

Example

SELECT o.id, f.value:sku::STRING FROM orders o, LATERAL FLATTEN(input => o.v:items) f;

Exam tip

LATERAL FLATTEN is the standard answer for turning a JSON array into rows.

Related terms