merge

Function merge 

pub fn merge(
    mask: &BooleanArray,
    truthy: &dyn Datum,
    falsy: &dyn Datum,
) -> Result<Arc<dyn Array>, ArrowError>
Expand description

Merges two arrays in the order specified by a boolean mask.

This algorithm is a variant of zip that does not require the truthy and falsy arrays to have the same length.

When truthy of falsy are Scalar, the single scalar value is repeated whenever the mask array contains true or false respectively.

§Example

 truthy
┌─────────┐  mask
│    A    │  ┌─────────┐                             ┌─────────┐
├─────────┤  │  true   │                             │    A    │
│    C    │  ├─────────┤                             ├─────────┤
├─────────┤  │  true   │                             │    C    │
│   NULL  │  ├─────────┤                             ├─────────┤
├─────────┤  │  false  │  merge(mask, truthy, falsy) │    B    │
│    D    │  ├─────────┤  ─────────────────────────▶ ├─────────┤
└─────────┘  │  true   │                             │   NULL  │
 falsy       ├─────────┤                             ├─────────┤
┌─────────┐  │  false  │                             │    E    │
│    B    │  ├─────────┤                             ├─────────┤
├─────────┤  │  true   │                             │    D    │
│    E    │  └─────────┘                             └─────────┘
└─────────┘