TOMAP
- TOMAP(array, table)[source]
Converts an array of values into a map keyed by table rows.
This formula takes an array object and a table, and constructs a map where each row of the table is used as a key and the corresponding element of the array is used as the value. The array must have the same length as the number of rows in the table. If the lengths do not match, the formula evaluates to an error value.
- Parameters:
array (
Operand) –The array of values to convert to a map.
Supported types:
BOOLEAN_ARRAY
INTEGER_ARRAY
DECIMAL_ARRAY
STRING_ARRAY
DATE_ARRAY
TIME_ARRAY
DATETIME_ARRAY
table (
Table) –The table whose rows will be used as keys.
Supported types:
TABLE
- Return type:
- Returns:
A formula object that evaluates to a map whose keys are the rows of the given table and whose values come from the provided array.
Supported types:
BOOLEAN_MAP
INTEGER_MAP
DECIMAL_MAP
STRING_MAP
DATE_MAP
TIME_MAP
DATETIME_MAP
- Raises:
ValueError – If either input is not a valid type.
Examples
Using a string array:
TOMAP(["A", "B", "C"], MyTable) # Returns a map from table rows to strings
Mismatched array and table sizes:
TOMAP([1, 2], MyTable) # Evaluates to #ERROR