ARRAY_LOOKUP

All functions > ARRAY > ARRAY_LOOKUP

Returns the value corresponding to a lookup key using parallel key-value arrays.

Syntax

ARRAY_LOOKUP(lookup_key: K, keys: ARRAY<K>, values: ARRAY<V>) → V
sql

Type Parameters:

  • K: Any comparable type

  • V: Any type

Arguments

ParameterTypeRequiredDescription
lookup_keyKYesThe key to search for
keysARRAY<K>YesArray of keys
valuesARRAY<V>YesArray of values (parallel to keys)

Returns

Value type - The value at the same position as the key

Notes

  • Uses two parallel arrays: one for keys, one for values
  • Returns the value at the same index where the key is found
  • Returns NULL if key is not found
  • Only returns the first match if key appears multiple times
  • Arrays must be same length
Last update at: 2025/10/13 10:23:46