Oharra
Baimena behar duzu orria atzitzeko. Direktorioetan saioa has dezakezu edo haiek alda ditzakezu.
Baimena behar duzu orria atzitzeko. Direktorioak alda ditzakezu.
Función
Se aplica a:
Databricks SQL
Databricks Runtime
Devuelve la posición de la primera repetición de element en array.
Sintaxis
array_position(array, element)
Argumentos
-
array: una expresión ARRAY con elementos comparables. -
element: expresión que coincide con los tipos de los elementos enarray.
Devoluciones
BIGINT.
La indexación de matriz comienza en 1. Si el valor del elemento es NULL, se devuelve un NULL.
Si el elemento no se encuentra en la matriz, se devuelve un 0.
Ejemplos
-- 1 exists twice. The function returns the first position
> SELECT array_position(array(3, 2, 1, 4, 1), 1);
3
-- this function cannot be used to find the position of a NULL element.
> SELECT array_position(array(3, NULL, 1), NULL)
NULL
> SELECT array_position(array(3, 2, 1), NULL)
NULL
-- The element is not found in the array
> SELECT array_position(array(3, 2, 1, 4, 1), 5)
0