Click to copy

• Reviewed for ksqlDB 0.29

How to Use Window Without Group By in ksqlDB

In ksqlDB, WINDOW clauses require a GROUP BY clause. A trick to overcome this limitation is to use a literal value like true as a grouping key.

For example, this query collects the name of all the products within the window interval.

SELECT 
  true, 
  FROM_UNIXTIME(WINDOWSTART),
  COLLECT_LIST(name)
FROM product_updates
WINDOW TUMBLING (SIZE 1 DAY) 
GROUP BY true 
EMIT CHANGES;
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