> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/functions/sketch/distinctcounttuplesketch.md).

# DISTINCTCOUNTTUPLESKETCH

The [Tuple Sketch](https://datasketches.apache.org/docs/Tuple/TupleOverview.html) is an extension of the [Theta Sketch](https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html). Tuple sketches store an additional summary value with each retained entry which makes the sketch ideal for summarizing attributes such as impressions or clicks. Tuple sketches are interoperable with the Theta Sketch and enable set operations over a stream of data, and can also be used for cardinality estimation.

## Signature

> distinctCountTupleSketch(**\<tupleSketchColumn>, \<tupleSketchParams>**) -> Long

* `tupleSketchColumn` (required): Name of the column to aggregate on. This must be an existing tuple sketch serialized as bytes.
* `tupleSketchParams` (required): Semicolon-separated parameter string for constructing the intermediate tuple-sketches.
  * The supported parameters are:
  * `nominalEntries`: The nominal entries used to create the sketch. (Default 65536)
  * `accumulatorThreshold`: How many sketches should be kept in memory before merging. (Default 2)

These examples are based on the [Batch Quick Start](/start-here/quick-start.md#batch-processing). A new Tuple Sketch metric called `playerHomeRuns` was created during ingestion by updating the ingestion config as follows:

```json
	"ingestionConfig": {
		"transformConfigs": [
			{
				"columnName": "playerHomeRuns",
				"transformFunction": "toIntegerSumTupleSketch(playerID, homeRuns)"
			}
		]
	}
```

The `distinctCountTupleSketch` function can be used to extract an estimate of the number of unique items in a Tuple sketch.

```sql
select distinctCountTupleSketch(playerHomeRuns) as value
from baseballStats 
```

| value |
| ----- |
| 17549 |

```sql
select distinctCountTupleSketch(playerHomeRuns, 'nominalEntries=65536;accumulatorThreshold=10) as value
from baseballStats 
```

| value |
| ----- |
| 17549 |

This function can also be used with the multi-stage engine (MSE).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pinot.apache.org/functions/sketch/distinctcounttuplesketch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
