CREATE VIEW
There are two types of views in Timeplus: logical view (or just view ) and materialized view.
You can create views for all kinds of queries, and refer to the views in other queries.
- If the view is created based on a streaming query, then you can consider the view as a virtual stream. For example,
create view view1 as select * from my_stream where c1 ='a'
will create a virtual stream to filter all events with c1 = 'a'. You can use this view as if it's another stream, e.g.select count(*) from tumble(view1,1m) group by window_start
Creating a view won't trigger any query execution. Views are evaluated only when other queries refer to it. - a view could be a bounded stream if the view is created with a bounded query using table() function, e.g.
create view view2 as select * from table(my_stream)
then each time you runselect count(*) from view2
will return the current row number of the my_stream immediately without waiting for the future events.
Please note, once the view is created based on a streaming query, you cannot turn it to a bounded stream via table(streaming_view)
To create a vanilla view:
CREATE VIEW [IF NOT EXISTS] <view_name> AS <SELECT ...>