The distinct operator in APL (Axiom Processing Language) returns a unique set of values from a specified field or set of fields. This operator is useful when you need to filter out duplicate entries and focus only on distinct values, such as unique user IDs, event types, or error codes within your datasets. Use the distinct operator in scenarios where eliminating duplicates helps you gain clearer insights from your data, like when analyzing logs, monitoring system traces, or reviewing security incidents.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.

Usage

Syntax

| distinct FieldName1 [, FieldName2, ...]

Parameters

  • FieldName1, FieldName2, ...: The fields to include in the distinct operation. If you specify multiple fields, the result will include rows where the combination of values across these fields is unique.

Returns

The distinct operator returns a dataset with unique values from the specified fields, removing any duplicate entries.

Use case examples

In this use case, the distinct operator helps identify unique users who made HTTP requests in a system.

Query

['sample-http-logs']
| distinct id

Run in Playground

Output

id
user_123
user_456
user_789

This query returns a list of unique user IDs that have made HTTP requests, filtering out duplicate user activity.

  • count: Returns the total number of rows. Use it to count occurrences of data rather than filtering for distinct values.
  • summarize: Allows you to aggregate data and perform calculations like sums or averages while grouping by distinct values.
  • project: Selects specific fields from the dataset. Use it when you want to control which fields are returned before applying distinct.