> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# ds_theta_union

> 对两个 Apache DataSketches Theta 草图执行并集运算，返回不同值估计为 |A∪B| 的序列化紧凑草图。

对两个序列化的 Apache DataSketches Theta 草图执行标量两两并集。返回一个序列化的紧凑草图，其不同值估计为 `|A ∪ B|`。如果任一输入为 `NULL`，则返回 `NULL`。

如需对多个草图一次性进行聚合式并集，请使用 [ds\_theta\_combine](/documents/cn/4.2/sql-reference/sql-functions/aggregate-functions/ds_theta_combine.md)。

## 语法

```Haskell theme={null}
VARBINARY ds_theta_union(sketch_a, sketch_b)
```

* `sketch_a`、`sketch_b`: `VARBINARY` 紧凑 theta 草图。

## 示例

```SQL theme={null}
SELECT ds_theta_estimate(ds_theta_union(a.sk, b.sk))
FROM cohort_a a JOIN cohort_b b USING (day);
```

## 关键词

DS\_THETA\_UNION, DS\_THETA\_INTERSECT, DS\_THETA\_A\_NOT\_B, DS\_THETA\_COMBINE


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.