メインコンテンツへスキップ
uniqTheta 関数は、2 つの uniqThetaSketch オブジェクトに対して、∪ / ∩ / × (union/intersect/not) などの集合演算を行い、その結果を含む新しい uniqThetaSketch オブジェクトを返します。 uniqThetaSketch オブジェクトは、集約関数 uniqTheta に -State を付けて作成します。 UniqThetaSketch は、近似値の集合を格納するデータ構造です。 詳細は、Theta Sketch Framework を参照してください。

uniqThetaUnion

2 つの 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

2 つの 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

2 つの 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 │
└─────────┴───────────────┴───────────────┘
関連項目
最終更新日 2026年6月10日