> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-home-button.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> uniqTheta 関数のドキュメント

# uniqTheta 関数

uniqTheta 関数は、2 つの uniqThetaSketch オブジェクトに対して、∪ / ∩ / × (union/intersect/not) などの集合演算を行い、その結果を含む新しい uniqThetaSketch オブジェクトを返します。

uniqThetaSketch オブジェクトは、集約関数 uniqTheta に -State を付けて作成します。

UniqThetaSketch は、近似値の集合を格納するデータ構造です。
詳細は、[Theta Sketch Framework](https://datasketches.apache.org/docs/Theta/ThetaSketches.html#theta-sketch-framework) を参照してください。

<div id="uniqthetaunion">
  ## uniqThetaUnion
</div>

2 つの uniqThetaSketch オブジェクトの和集合 (集合演算 ∪) を計算し、その結果として新しい uniqThetaSketch を返します。

```sql theme={null}
uniqThetaUnion(uniqThetaSketch,uniqThetaSketch)
```

**引数**

* `uniqThetaSketch` – uniqThetaSketchオブジェクト。

**例**

```sql theme={null}
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 );
```

```text theme={null}
┌─a_union_b─┬─a_cardinality─┬─b_cardinality─┐
│         4 │             2 │             3 │
└───────────┴───────────────┴───────────────┘
```

<div id="uniqthetaintersect">
  ## uniqThetaIntersect
</div>

2 つの `uniqThetaSketch` オブジェクトに対して積集合の計算 (集合演算 ∩) を行い、その結果として新しい `uniqThetaSketch` を返します。

```sql theme={null}
uniqThetaIntersect(uniqThetaSketch,uniqThetaSketch)
```

**引数**

* `uniqThetaSketch` – uniqThetaSketch オブジェクト。

**例**

```sql theme={null}
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 );
```

```text theme={null}
┌─a_intersect_b─┬─a_cardinality─┬─b_cardinality─┐
│             1 │             2 │             3 │
└───────────────┴───────────────┴───────────────┘
```

<div id="uniqthetanot">
  ## uniqThetaNot
</div>

2 つの uniqThetaSketch オブジェクトに対して a\_not\_b 計算 (集合演算 ×) を実行し、その結果として新しい uniqThetaSketch を返します。

```sql theme={null}
uniqThetaNot(uniqThetaSketch,uniqThetaSketch)
```

**引数**

* `uniqThetaSketch` – uniqThetaSketch オブジェクト。

**例**

```sql theme={null}
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 );
```

```text theme={null}
┌─a_not_b─┬─a_cardinality─┬─b_cardinality─┐
│       2 │             3 │             2 │
└─────────┴───────────────┴───────────────┘
```

**関連項目**

* [uniqThetaSketch](/ja/reference/functions/aggregate-functions/uniqthetasketch)

{/*AUTOGENERATED_START*/}
