Fluent Bit Stream Processor: CREATE STREAM

by edsiper
GNU/Linux ◆ xterm-256color ◆ bash 2985 views

The following demo shows how to create streams of data based on results from previous queries.

The recently introduced CREATE STREAM statement allows to create a stream of data based on the results of a query from a previous stream, the example takes an input file with apache logs in JSON format and then 3 queries do stream processing:

[STREAM_TASK]
     Name  res1
     Exec  CREATE STREAM res1 AS SELECT host, code AS http_status, size FROM STREAM:apache;

[STREAM_TASK]
     Name  res2
     Exec  CREATE STREAM res2 AS SELECT * FROM STREAM:res1;

[STREAM_TASK]
     Name  res3
     Exec  CREATE STREAM res3 AS SELECT COUNT(http_status), avg(size)  FROM STREAM:res2;

Note that in the last stream task (res3) we are using the aggregation functions COUNT() and AVG().