First / List Layer

Extract the first element from each variable-length list. Similar to list[0] indexing in Python or head(1) in R. Returns a column containing the first element of each list.

Example transformation:

listsfirst
[1, 2, 3, 4]1
[apple, banana]apple
[true]true
[null, 2, 3]null
[]null

Common applications:

  • Getting most recent events in time-ordered lists
  • Extracting primary categories from tag lists
  • Finding initial states in sequences
  • Accessing first readings in measurement series
  • Getting top priorities from ranked items
  • Extracting lead elements from variable sequences

Note: Lists can have any length, including empty. Returns null for empty lists or if first element is null. Preserves original element type. Particularly useful for accessing initial elements in varying-length sequences.

Table
0
0
Table

Select

column

The variable-length list column to access. Supports various types:

  • Numeric lists: [1, 2, 3], [4, 5]
  • String lists: [first, second, third], [single]
  • Boolean lists: [true, false], [true]
  • Date/time lists: [2024-01-01, 2024-01-02], [] Lists can have different lengths, including empty lists

Name for the new column. If not provided, the system generates a unique name. If AsColumn matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.