count_distinct

The number of distinct non-null values (keys as the sort order sees them: -0 = +0, one NaN).

AggregateDeterministic

Flags

Flag Value
Kind aggregate
Nulls never null
Deterministic yes
Order matters no
Decomposable yes, by the set of keys

Example

A pipeline from the language's tested corpus that uses count_distinct, over the example tables.

Hint
from orders
aggregate {med = median(amount), p90 = quantile(amount, q: 9e-1), p10 = quantile(price, q: 1e-1, method: "disc"), v = var_samp(price), sd = stddev_samp(price), m = mode(status), d = count_distinct(customer)} by:{rush}

In a plan:

JSON
{
  "args": [
    {
      "col": 1
    }
  ],
  "fn": "count_distinct"
}