Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The most different parts between usual SQL and CQL is the FROM part, because you have the possibility to definie windows. CQL defines them by squared brackets.

The following parameters are available for time based windows (TIME):

  • SIZE: Defines the size of the window, e.g. 60 MINUTES
  • ADVANCE: After what time will the window move

The following parameters are available for element based windows (TUPLE)

...

There are 3 different windows you can define: an unbounded window, a time-based window and a tuple-based window.

An unbounded window is defined by the keyword UNBOUNDED. It sets the end timestamp to infinite. Example:

Code Block
SELECT * FROM bid [UNBOUNDED]

Since an unbounded window does not limit the validity of a stream element (in fact it is not really a window), the declaration of UNBOUNDED is optional. You get the same result without a window declaration. You can use the UNBOUNDED keyword to highlight that no window is defined.

A time-based window is defined by the size of the window as time span and an optional advance parameter. The latter defines after what time span the window should move (same unit as size). Additional, a partition attribute can be defined. Syntax:

Code Block
SELECT * FROM <source> [SIZE <size> <unit> TIME]
 
SELECT * FROM <source> [SIZE <size> <unit> ADVANCE <advance size> TIME]
 
SELECT * FROM <source> [SIZE <size> <unit> TIME PARTITION BY bid.auction]
 
SELECT * FROM <source> [SIZE <size> <unit> ADVANCE <advance size> TIME PARTITION BY <partition attribute>]

Possible values for <unit> are:

  • SECONDS
  • MINUTES
  • HOURS
  • ...

A tuple-based window is defined by the size of the window as number of tuples and an optional advance parameter. The latter defines after how many tuples the window should move. Additional, a partition attribute can be defined. Syntax:

Code Block
SELECT * FROM <source> [SIZE <size> TUPLE]


SELECT * FROM <source> [SIZE <size> ADVANCE <advance size> TUPLE]


SELECT * FROM <source> [SIZE <size> TUPLE PARTITION BY bid.auction]


SELECT * FROM <source> [SIZE <size> ADVANCE <advance size> TUPLE PARTITION BY <partition attribute>]

 

...

Futher information about windows can be found here

...