Coalesce Columns
EasyData EngineeringArrayMathSortingSQL
Description
Given a list of equal-length columns (each an array that may contain nulls), return a single column where each position holds the first non-null value found by scanning the columns in order, like SQL COALESCE. If every column is null at a position, the result is null there.
Examples
Input:
[[null,2,null],[1,null,null],[9,9,3]]Output:
[1,2,3]Explanation:
At each position the first column that holds a value wins, mirroring how a coalesce picks the earliest non-null across the sources.
Input:
[[1,2,3]]Output:
[1,2,3]Explanation:
At each position the first column that holds a value wins, mirroring how a coalesce picks the earliest non-null across the sources.
Input:
[[null,null],[null,5]]Output:
[null,5]Explanation:
At each position the first column that holds a value wins, mirroring how a coalesce picks the earliest non-null across the sources.
Constraints
- •
1 ≤ number of columns ≤ 100 - •
1 ≤ column length ≤ 10⁴