## SQL Statement Syntax The following is the SQL statement syntax supported by Fluent Bit stream processor in EBNF form. For readability, we assume the conventional definition for integer, float and string values. A single quote in a constant string literal has to be escaped with an extra one. For instance, the string representation of `O'Keefe` in the query will be `'O''Keefe'`. ```xml := | | CREATE STREAM WITH () AS := SELECT FROM [WHERE ] [WINDOW TUMBLING ( SECOND) | WINDOW HOPPING ( SECOND, ADVANCE BY SECOND)] [GROUP BY ] := '*' | := | , := | AS := | := AVG() | SUM() | COUNT() | COUNT(*) | MIN() | MAX() | TIMESERIES_FORECAST(, ) := STREAM: | TAG: := | | | () | NOT | AND | OR | @record.contains() | IS NULL | IS NOT NULL := | := [] | [] := = | != | <> | < | <= | > | >= := := | | _ | := true | false | | | '' ``` In addition to the common aggregation functions, Stream Processor provides the timeseries function `TIMESERIES_FORECAST`, which uses [simple linear regression algorithm]( [ x x x x x ... x x x x x ] <- 2 sec -><--------- 10 sec --------> [ x x x x x ... x x x x x ] <- 2 sec -><--------- 10 sec --------> ``` ### Tumbling window A tumbling window is similar to a hopping window where `ADVANCE BY` value is the same as the window size. That means the new window doesn't include any record from the previous one. For example. the tumbling window `WINDOW TUMBLING (10 SECOND)` works like this: ``` [ x x x x x ... x x x x x ] <--------- 10 sec --------> [ x x x x x ... x x x x x ] <--------- 10 sec --------> [ x x x x x ... x x x x x ] <--------- 10 sec --------> ```