Unnest / Struct Layer

Unnest (flatten) a struct column into separate columns. Similar to Polars unnest(), pandas json_normalize(), or R's unnest() function. Expands nested structure fields into individual columns in the dataframe.

Example transformation:

Input struct column 'data':

data
{name: 'John', age: 30}
{name: 'Mary', age: 25}

After unnesting:

nameage
John30
Mary25

Common applications:

  • Expanding nested JSON data
  • Processing API responses
  • Flattening complex data structures
  • Working with grouped statistics
  • Expanding value_counts results
  • Processing nested analytics results

Note: Column names in the output are derived from the struct field names. Existing columns with the same names will be replaced.

Table
0
0
Table

Select

column

The struct column to unnest. Common input types:

  • JSON-like nested structures
  • Results from aggregation operations
  • Grouped statistics output
  • Nested API data
  • Complex data structures

Example struct formats:

  • {field1: value1, field2: value2}
  • {count: 5, proportion: 0.25}
  • {stats: {mean: 10, std: 2}}