First / Array Layer

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

Example transformation (arrays of length 3):

arraysfirst
[1, 2, 3]1
[a, b, c]a
[true, false, true]true
[null, 2, 3]null

Common applications:

  • Getting primary values
  • Extracting initial elements
  • Processing first occurrences
  • Default value selection

Note: Arrays must have the same fixed length across all rows. Returns null if first element is null. Preserves original element type.

Table
0
0
Table

Select

column

The fixed-length array column to access. Supports various array types:

  • Numeric arrays: [1, 2, 3]
  • String arrays: [a, b, c]
  • Boolean arrays: [true, false, true]
  • Date/time arrays: [2024-01-01, 2024-01-02, 2024-01-03] All arrays must have the same length

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.