ARRAY_EXCEPT 함수 - Amazon Redshift

Amazon Redshift는 패치 198부터 새 Python UDF 생성을 더 이상 지원하지 않습니다. 기존 Python UDF는 2026년 6월 30일까지 계속 작동합니다. 자세한 내용은 블로그 게시물을 참조하세요.

ARRAY_EXCEPT 함수

두 번째 배열에 없는 첫 번째 배열의 요소를 유지하여 두 배열 간의 차이를 반환합니다. 함수는 Null 안전이므로 Null이 알려진 객체로 취급됩니다.

구문

ARRAY_EXCEPT( array1, array2 [, distinct] )

인수

array1

첫 번째 배열을 지정하는 SUPER 표현식입니다.

array2

두 번째 배열을 지정하는 SUPER 표현식입니다.

distinct

고유 요소만 반환할지 여부를 지정하는 부울 값입니다.

  • 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.

기본값은 FALSE입니다.

반환 타입

ARRAY_EXCEPT 함수는 SUPER 형식을 반환합니다.

예제

다음 예제에서는 ARRAY_EXCEPT 함수를 보여 줍니다.

SELECT ARRAY_EXCEPT(ARRAY('a','b','c'), ARRAY('b','c','d')); array_except -------------- ["a"] (1 row)

다중 세트 의미 체계:

SELECT ARRAY_EXCEPT(ARRAY('b','b','b','b'), ARRAY('b','b')); array_except -------------- ["b","b"] (1 row)

의미 체계 설정:

SELECT ARRAY_EXCEPT(ARRAY('a','b','b'), ARRAY('b'), TRUE); array_except -------------- ["a"] (1 row)

Null이 알려진 객체로 처리됩니다.

SELECT ARRAY_EXCEPT(ARRAY('a',NULL), ARRAY(NULL)); array_except -------------- ["a"] (1 row)

다음 사항도 참조하세요.