Click to copy

• Reviewed for ksqlDB 0.29

How to Get Distinct Values Within Window in ksqlDB

T o select distinct values within a window , use COLLECT_SET:

SELECT 
  true, 
  collect_set(category)
FROM posts
WINDOW TUMBLING (SIZE 1 HOUR) 
GROUP BY true
EMIT CHANGES;
It returns an array, so you can use an array function to further aggregate the result.
Discover what readers are saying
topictale
Get easy to digest how-tos on ksqlDB
Sign up
Please read our Privacy Policy to understand how we protect and manage your data.
You may also like