# SELECT (Stream)
Continuously pulls records from the stream(s) specified. It is usually used in an interactive CLI to monitor realtime changes of data. Note that the query writes records to a random-named stream which is hidden from users.
# Synopsis
SELECT <* | expression [ AS field_alias ] [, ...]>
FROM stream_name [, ...]
[ WHERE search_condition ]
[ GROUP BY field_name [, window_type] ]
EMIT CHANGES;
1
2
3
4
5
2
3
4
5
# Notes
expression
can be a field name, a constant, or their association, such astemperature
,weather.humidity
,114514
,1 + 2
,SUM(productions)
and`COUNT(*)`
. Note that the last one is a raw column name which is used when a column name contains function names. See Special Characters.some_interval
represents a period of time. See Intervals.window_type
specifies the type of time window:window_type ::= TUMBLING some_interval | HOPPING some_interval some_interval | SLIDING some_interval
1
2
3search_condition
is actually a boolean expression:search_condition ::= [NOT] predicate [ <AND | OR> predicate [, ...] ] predicate ::= expression comp_op expression comp_op ::= = | <> | > | < | >= | <=
1
2
3
# Examples
- A simple query:
SELECT * FROM my_stream EMIT CHANGES;
1
- Filtering rows:
SELECT temperature, humidity FROM weather WHERE temperature > 10 AND humidity < 75 EMIT CHANGES;
1
- Joining streams:
SELECT stream1.temperature, stream2.humidity FROM stream1, stream2 WHERE stream1.humidity = stream2.humidity EMIT CHANGES;
1
- Grouping records:
SELECT COUNT(*) FROM weather GROUP BY cityId, TUMBLING (INTERVAL 10 SECOND) EMIT CHANGES;
1
← DROP CONNECTOR INSERT →