array_array

Function array_array 

Source
fn array_array<O: OffsetSizeTrait>(
    args: &[ArrayRef],
    data_type: DataType,
) -> Result<ArrayRef>
Expand description

Convert one or more [ArrayRef] of the same type into a ListArray or ‘LargeListArray’ depending on the offset size.

§Example (non nested)

Calling array(col1, col2) where col1 and col2 are non nested would return a single new ListArray, where each row was a list of 2 elements:

┌─────────┐   ┌─────────┐           ┌──────────────┐
│ ┌─────┐ │   │ ┌─────┐ │           │ ┌──────────┐ │
│ │  A  │ │   │ │  X  │ │           │ │  [A, X]  │ │
│ ├─────┤ │   │ ├─────┤ │           │ ├──────────┤ │
│ │NULL │ │   │ │  Y  │ │──────────▶│ │[NULL, Y] │ │
│ ├─────┤ │   │ ├─────┤ │           │ ├──────────┤ │
│ │  C  │ │   │ │  Z  │ │           │ │  [C, Z]  │ │
│ └─────┘ │   │ └─────┘ │           │ └──────────┘ │
└─────────┘   └─────────┘           └──────────────┘
  col1           col2                    output

§Example (nested)

Calling array(col1, col2) where col1 and col2 are lists would return a single new ListArray, where each row was a list of the corresponding elements of col1 and col2.

┌──────────────┐   ┌──────────────┐        ┌─────────────────────────────┐
│ ┌──────────┐ │   │ ┌──────────┐ │        │ ┌────────────────────────┐  │
│ │  [A, X]  │ │   │ │    []    │ │        │ │    [[A, X], []]        │  │
│ ├──────────┤ │   │ ├──────────┤ │        │ ├────────────────────────┤  │
│ │[NULL, Y] │ │   │ │[Q, R, S] │ │───────▶│ │ [[NULL, Y], [Q, R, S]] │  │
│ ├──────────┤ │   │ ├──────────┤ │        │ ├────────────────────────│  │
│ │  [C, Z]  │ │   │ │   NULL   │ │        │ │    [[C, Z], NULL]      │  │
│ └──────────┘ │   │ └──────────┘ │        │ └────────────────────────┘  │
└──────────────┘   └──────────────┘        └─────────────────────────────┘
     col1               col2                         output