Skip to main content
Aggregate · Window
NULL values are ignored. An empty input returns NULL, whether requesting one percentile or an array of percentiles.

Syntax

A window function keeps each input row and adds a result for that row. PARTITION BY groups rows with matching values; without it, all input rows form one group.

Aggregate

  • Requires native execution and a source database context other than PRESTO.

Window

  • Requires native execution and a source database context other than PRESTO.
  • Use a frame that includes all rows in the group or starts at the first row (UNBOUNDED PRECEDING). Sliding frames that drop earlier rows are not supported. RANGE frames with a numeric or time offset are not supported.

Arguments

Aggregate and window

Returns

  • Type: same type as value, or ARRAY<same type as value>
  • NULL behavior: NULL values are ignored. An empty input returns NULL, whether requesting one percentile or an array of percentiles.
  • Empty input: Returns NULL on empty input.
  • Shape: Scalar fraction returns scalar; array fractions return an array of matching length.
  • Ordering: Array result order follows requested fractions.

Properties

  • Approximation bound: Relative rank error is 1/accuracy; default accuracy is 10000. This is a rank-error statement, not an absolute numeric-value error bound.

Usage notes

  • Fraction and accuracy must be constant expressions. They cannot vary by row.
  • Higher accuracy uses more memory. Approximate results can vary with the order in which values are processed.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
  • DISTINCT removes duplicates in grouped aggregation. Do not use it to remove duplicates in a window call.

Examples

Median estimate

  • Requires native execution and a source database context other than PRESTO.

Estimate the upper quartile

This small dataset gives the result shown; percentile estimates can differ from an exact percentile calculation.

Limitations

  • Sliding windows that drop earlier rows are not supported. Start the frame at the first row in the group.
  • PERCENTILE_APPROX is available with native execution outside the PRESTO source context. It is not available with Java execution.
Last modified on October 15, 2026