Print

FROM

The FROM clause is mandatory and it sets the data sources for the query, from which data can be referenced in conditions and in selected fields.

What types of data sources can a query have?

  1. WINDOWS: you can select data from any window(s) in RioDB. A query can involve multiple windows.
  2. STREAMS: You can select data from any stream in RioDB. But only one stream (whichever is listed first) will drive the query.

In RioDB, each time the stream receives a new message, all queries associated with that stream will be executed. However, a query can only be associated with one stream.
Clarifying. Suppose you have a stream of issues reported by phone and another stream of issues reported by email. You may create a query that involves windows and aggregations from both streams in the same query. However, the query can be set to be executed everytime there’s a new message from the phone stream, OR every time there’s a new message from the email stream, but not both. If you need executions for both, then you need to create two separate queries, one driven by the phone stream, and the other driven by the email stream.

Unless the stream is explicitly specified, RioDB tries to guess the driving stream for a query. For example, if you are only selecting data from one window, you need not to specify the stream, as RioDB will automatically include the stream that feeds values to that window as the driving stream to execute your query.

Syntax

Data sources are separated by commas. Newlines are ignored, but useful for code readability:

FROM <source 1>,
     <source 2>,
     <...>,
     <source n>

Sources may have an alias to simplify conditions and selected references:

FROM <source 1> a,
     <source 2> b,
     <...>,
     <source n> c

Example

SELECT ...
FROM my_stock_stream s,
     last_100_bids_on_tsla t,
     last_100_bids_on_appl

Using aliases:

SELECT ...
FROM my_stock_stream s,
     last_100_bids_on_tsla t,
     last_100_bids_on_appl a

Referencing aliases is subsequently allowed in selected fields:

SELECT t.SUM, a.SUM  

Referencing aliases is subsequently allowed in conditions:

WHEN t.SUM > a.SUM  

Table of Contents
Scroll to Top