Combines one array containing keys and another array containing values into an Object of key-value pairs. |
If the number of key elements is greater than the number of value elements, null values are generated for the missing values in the output Object. If the number of value elements is greater, the DEFAULT_KEY
value (third parameter) is applied.
Array literal reference example:
arraystomap(["A","B"],["1","2","3"]) |
Output: Returns an Object associating keys from the first array with values from the second array.
Column reference example:
arraystomap(array1,array2, 'extraProps') |
Output: Returns an Object pairing the elements of the arrays as key-value pairs. Any extra values in array2
are assigned to the extraProps
key.
Function reference example:
arraystomap(array1,concat([array2,array3])) |
Output: Returns an Object pairing the elements of array1
and the array created by concatenating array2
and array3
.
arraystomap(array_keys,array_values, ['DEFAULT KEY']) |
Argument | Required? | Data Type | Description |
---|---|---|---|
array_keys | Y | string or array | Name of column, array literal, or function returning an array whose elements are the keys for the generated Object |
array_values | Y | string or array | Name of column, array literal, or function returning an array whose elements are the values for the generated Object |
DEFAULT_KEY | N | string literal | Any extra values are assigned to this specified key |
Name of the array column, array literal, or function returning an array whose elements you want to use as the keys for the Object.
Required? | Data Type | Example Value |
---|---|---|
Yes | String (column reference, function returning an array) or array literal | myKeys |
Name of the array column, array literal, or function returning an array whose elements you want to use as the values in the Object.
Required? | Data Type | Example Value |
---|---|---|
Yes | String (column reference, function returning an array) or array literal | myValues |
If there are extra elements in the second array, they are assigned to the key that is defined by this parameter.
Required? | Data Type | Example Value |
---|---|---|
No | String literal | 'extraProperties' |