Amazon Redshift non supporterà più la creazione di nuovi Python UDFs a partire dalla Patch 198. Python esistente UDFs continuerà a funzionare fino al 30 giugno 2026. Per ulteriori informazioni, consulta il post del blog
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Funzione ARRAY_EXCEPT
Restituisce la differenza tra due matrici mantenendo gli elementi del primo array che non esistono nel secondo array. La funzione è sicura per NULL, il che significa che tratta i dati NULLs vengono trattati come oggetti noti.
Sintassi
ARRAY_EXCEPT( array1, array2 [, distinct] )
Arguments (Argomenti)
- matrice 1
-
Un'espressione SUPER che specifica il primo array.
- matrice 2
-
Un'espressione SUPER che specifica il secondo array.
- distinct
-
Un valore booleano che specifica se restituire solo elementi distinti:
- distinct = FALSE: Multi-set semantics apply. Each occurrence of an element in the first array is matched against occurrences in the second array. If the first array has more occurrences of an element than the second array, the extra occurrences are preserved in the result.
- distinct = TRUE: Set semantics apply. Both arrays are treated as sets, ignoring duplicate elements. Elements from the first array are removed if they exist anywhere in the second array, regardless of occurrence count.
L'impostazione predefinita è FALSE.
Tipo restituito
La funzione ARRAY_EXCEPT restituisce un tipo SUPER.
Esempio
Gli esempi seguenti mostrano la funzione ARRAY_EXCEPT.
SELECT ARRAY_EXCEPT(ARRAY('a','b','c'), ARRAY('b','c','d')); array_except -------------- ["a"] (1 row)
Semantica a set multipli:
SELECT ARRAY_EXCEPT(ARRAY('b','b','b','b'), ARRAY('b','b')); array_except -------------- ["b","b"] (1 row)
Semantica degli insiemi:
SELECT ARRAY_EXCEPT(ARRAY('a','b','b'), ARRAY('b'), TRUE); array_except -------------- ["a"] (1 row)
NULLs vengono trattati come oggetti noti.
SELECT ARRAY_EXCEPT(ARRAY('a',NULL), ARRAY(NULL)); array_except -------------- ["a"] (1 row)