Skip to main content

vortex_array/compute/
zip.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_error::VortexResult;
5use vortex_mask::Mask;
6
7use crate::Array;
8use crate::ArrayRef;
9use crate::IntoArray;
10use crate::builtins::ArrayBuiltins;
11
12/// Performs element-wise conditional selection between two arrays based on a mask.
13///
14/// Returns a new array where `result[i] = if_true[i]` when `mask[i]` is true,
15/// otherwise `result[i] = if_false[i]`.
16///
17/// Null values in the mask are treated as false (selecting `if_false`). This follows
18/// SQL semantics (DuckDB, Trino) where a null condition falls through to the ELSE branch,
19/// rather than Arrow's `if_else` which propagates null conditions to the output.
20#[deprecated(note = "use if_true.zip(if_false, mask) via ArrayBuiltins instead")]
21pub fn zip(if_true: &dyn Array, if_false: &dyn Array, mask: &Mask) -> VortexResult<ArrayRef> {
22    if_true
23        .to_array()
24        .zip(if_false.to_array(), mask.clone().into_array())
25}