SELECT (View)
Selecting from a view is a very fast operation that takes advantage of the concept of a view. So it has a more restricted syntax than selecting from a stream:
SELECT
clause can only contain*
or column names with/without aliases. Other ones such as constants, arithmetical expressions, aggregate/scalar functions, etc. are not allowed. And the column names should be in theSELECT
clause of the query when creating the corresponding view.- clause can only contain ONE view name. Clauses such as
JOIN
are not allowed. WHERE
clause can only contain ONE conditional expression in the form ofcolumn_name = constant
. And thecolumn_name
has to be the same as which in the clause when creating the corresponding view and theconstant
has to be a literal whose value is known at compile time, see constant.
// CREATE VIEW my_view AS SELECT a, b, SUM(a), COUNT(*) AS cnt FROM foo GROUP BY b EMIT CHANGES;