---
title: tuple_union_integer function
description: Learn the syntax of the tuple\_union\_integer function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_union_integer
---

# `tuple_union_integer` function

**Applies to:** ![check marked yes](https://docs.databricks.com/gcp/en/images/icons/check.png) Databricks Runtime 18.1 and above

Merges exactly two TupleSketch binary representations with integer summaries using set union.

## Syntax

```
tuple_union_integer ( first, second [, lgNomEntries [, mode ]] )
```

## Arguments

* **first**: A TupleSketch in binary format with integer summaries.
* **second**: A TupleSketch in binary format with integer summaries.
* **lgNomEntries**: An optional `INTEGER` literal specifying the log-base-2 of nominal entries. Must be between 4 and 26, inclusive. The default is 12.
* **mode**: An optional `STRING` literal specifying the aggregation mode. Valid values: `'sum'`, `'min'`, `'max'`, `'alwaysone'`. The default is `'sum'`.

## Returns

A `BINARY` value containing the merged TupleSketch with integer summaries.

## Notes

* For merging more than two sketches, use the aggregate [tuple\_union\_agg\_integer](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_union_agg_integer.md) function.

## Common error conditions

* [TUPLE\_INVALID\_INPUT\_SKETCH\_BUFFER](https://docs.databricks.com/gcp/en/error-messages/error-classes.md#tuple_invalid_input_sketch_buffer)

## Examples

```sql
> SELECT tuple_sketch_estimate_integer(
    tuple_union_integer(
      tuple_sketch_agg_integer(col1, val1),
      tuple_sketch_agg_integer(col2, val2)
    )
  ) FROM VALUES (1, 1, 4, 4), (2, 2, 5, 5), (3, 3, 6, 6) tab(col1, val1, col2, val2);
6.0
```

## Related

* [`tuple_union_double` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_union_double.md)
* [`tuple_union_theta_integer` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_union_theta_integer.md)
* [`tuple_union_agg_integer` aggregate function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_union_agg_integer.md)
