anyHeavy

anyHeavy

heavy hitters 알고리즘을 사용해서 자주 나타나는 값을 선택하는 집계 함수예요. 특정 값이 쿼리의 각 실행 스레드에서 절반 이상의 경우에 나타난다면 그 값을 반환해요.

출처: 문서

본문

v1.1.0에서 도입됐어요.

heavy hitters 알고리즘을 사용하여 자주 나타나는 값을 선택해요. 쿼리의 각 실행 스레드에서 절반 이상의 경우에 나타나는 값이 있으면 그 값이 반환돼요.

일반적으로 결과는 비결정적이에요.

구문 (Syntax)

anyHeavy(column)

인자 (Arguments)

  • column — 컬럼 이름. String

반환 값 (Returned value)

자주 나타나는 값을 반환해요. 결과는 비결정적이에요. Any

예시 (Examples)

사용 예시:

Query

CREATE TABLE ontime (AirlineID UInt32) ENGINE = Memory;

-- Three quarters of the flights belong to one airline, so it occurs in more than half of the
-- rows seen by every thread and the result is the same on every run.
INSERT INTO ontime SELECT if(number % 4 = 0, 19393, 19690) FROM numbers(1000);

SELECT anyHeavy(AirlineID) AS res
FROM ontime;

Response

┌───res─┐
│ 19690 │
└───────┘

더 알아보기 (Learn more)