[SQL][ClickHouse] 배열 함수

강민경·2024년 11월 5일

empty

입력 배열이 비어 있는지 확인합니다.

구문

empty([x])

배열에 요소가 포함되어 있지 않은 경우 배열은 비어 있는 것으로 간주됩니다.

Note
Can be optimized by enabling the optimize_functions_to_subcolumns setting. With optimize_functions_to_subcolumns = 1 the function reads only size0 subcolumn instead of reading and processing the whole array column. The query SELECT empty(arr) FROM TABLE; transforms to SELECT arr.size0 = 0 FROM TABLE;.

이 기능은 문자열 또는 UUID에서도 작동합니다.

전달인자

  • [x] - 입력 배열

반환 값

  • 빈 배열의 경우 1을 반환하거나 비어 있지 않은 배열의 경우 0을 반환합니다.

예시

Query:

SELECT empty([]);

Result:

empty(array())
1




notEmpty

입력 배열이 비어 있지 않은지 확인합니다.

구문

notEmpty([x])

배열에 하나 이상의 요소가 포함된 경우 배열은 비어 있지 않은 것으로 간주됩니다.

Note
Can be optimized by enabling the optimize_functions_to_subcolumns setting. With optimize_functions_to_subcolumns = 1 the function reads only size0 subcolumn instead of reading and processing the whole array column. The query SELECT notEmpty(arr) FROM table transforms to SELECT arr.size0 != 0 FROM TABLE.

이 기능은 문자열 또는 UUID에서도 작동합니다.

전달인자

  • [x] - 입력 배열

반환 값

  • 비어 있지 않은 배열의 경우 1을 반환하거나 비어 있는 배열의 경우 0을 반환합니다

예시

Query:

SELECT notEmpty([1,2]);

Result:

notEmpty([1, 2])
1




length

배열의 항목 수를 반환합니다. 결과 유형은 UInt64입니다. 이 함수는 문자열에서도 작동합니다.

optimize_functions_to_subcolumns 설정을 활성화하여 최적화할 수 있습니다. optimize_functions_to_subcolumns = 1을 사용하면 함수는 전체 배열 열을 읽고 처리하는 대신 크기 0 하위 열만 읽습니다. SELECT length(ar) FROM TABLE 쿼리는 SELECT arr.size0 FROM TABLE로 변환됩니다.

별칭: OCTET_LENGHT





emptyArrayUInt8

빈 UInt8 배열을 반환합니다.

구문

emptyArrayUInt8()

전달인자

없음.

반환 값

빈 배열.

예시

Query:

SELECT emptyArrayUInt8();

Result:

[]




emptyArrayUInt16

빈 UInt16 배열을 반환합니다.

구문

emptyArrayUInt16()

전달인자

없음.

반환 값

빈 배열.

예시

Query:

SELECT emptyArrayUInt16();

Result:

[]




emptyArrayUInt32

빈 UInt32 배열을 반환합니다.

구문

emptyArrayUInt32()

전달인자

없음.

반환 값

빈 배열.

예시

Query:

SELECT emptyArrayUInt32();

Result:

[]




emptyArrayUInt64

빈 UInt64 배열을 반환합니다.

구문

emptyArrayUInt64()

전달인자

없음.

반환 값

빈 배열.

예시

Query:

SELECT emptyArrayUInt64();

Result:

[]




profile
간단한 기록

0개의 댓글