Click to copy
Types • Reviewed for ksqlDB 0.29
How to Reduce or Combine Elements in Array in ksqlDB
To aggregate the values in an array into a single value by applying a custom function, you can use REDUCE
as follows:
SELECT
REDUCE(hourly_measurements, 0, (s, x) => MAX(s, x)) AS max_temperature
FROM
daily_temperature;
The stream in the example was created using the following statement, where hourly_measurements
has a number series of measurements taken at each particular date.
CREATE STREAM daily_temperature (
hourly_measurements ARRAY<DOUBLE>,
...
) WITH (...)
Was this article helpful?