uniqTheta 함수는 두 개의 uniqThetaSketch 객체에 대해 ∪ / ∩ / × (합집합/교집합/부정)과 같은 집합 연산을 수행하며, 그 결과를 포함하는 새로운 uniqThetaSketch 객체를 반환합니다.
uniqThetaSketch 객체는 -State가 붙은 집계 함수 uniqTheta로 생성됩니다.
uniqThetaSketch는 근사값으로 된 Set을 저장하는 데이터 구조입니다.
자세한 내용은 Theta Sketch Framework를 참조하십시오.
uniqThetaUnion
두 개의 uniqThetaSketch 객체에 대해 합집합 연산(집합 연산 ∪)을 수행하고, 결과로 새로운 uniqThetaSketch를 반환합니다.
uniqThetaUnion(uniqThetaSketch,uniqThetaSketch)
인수
uniqThetaSketch – uniqThetaSketch 객체입니다.
예제
SELECT finalizeAggregation(uniqThetaUnion(a, b)) AS a_union_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState',[1,2]) AS a, arrayReduce('uniqThetaState',[2,3,4]) AS b );
┌─a_union_b─┬─a_cardinality─┬─b_cardinality─┐
│ 4 │ 2 │ 3 │
└───────────┴───────────────┴───────────────┘
uniqThetaIntersect
두 개의 uniqThetaSketch 객체 사이의 교집합(집합 연산 ∩)을 계산하며, 결과로 새로운 uniqThetaSketch를 반환합니다.
uniqThetaIntersect(uniqThetaSketch,uniqThetaSketch)
인수
uniqThetaSketch – uniqThetaSketch 객체.
예제
SELECT finalizeAggregation(uniqThetaIntersect(a, b)) AS a_intersect_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState',[1,2]) AS a, arrayReduce('uniqThetaState',[2,3,4]) AS b );
┌─a_intersect_b─┬─a_cardinality─┬─b_cardinality─┐
│ 1 │ 2 │ 3 │
└───────────────┴───────────────┴───────────────┘
uniqThetaNot
두 개의 uniqThetaSketch 객체에 대해 a_not_b 계산(집합 차집합 연산)을 수행하며, 결과로 새로운 uniqThetaSketch를 반환합니다.
uniqThetaNot(uniqThetaSketch,uniqThetaSketch)
인자
uniqThetaSketch – uniqThetaSketch 객체.
예제
SELECT finalizeAggregation(uniqThetaNot(a, b)) AS a_not_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState',[2,3,4]) AS a, arrayReduce('uniqThetaState',[1,2]) AS b );
┌─a_not_b─┬─a_cardinality─┬─b_cardinality─┐
│ 2 │ 3 │ 2 │
└─────────┴───────────────┴───────────────┘
함께 보기