Search code examples
pipelinedb

Can table be used as a stream in PipelineDB


let's assume we have a table test_table like this

create table test_table(x integer);

Is it possible to create a continuous view from this table? Something like this:

create continuous view test_view as select sum(x) as x_sum from test_table;

When I run the above command I get the error:

test=# create continuous view test_view as select sum(x) as x_sum from test_table; ERROR: continuous queries must include a stream in the FROM clause LINE 1: ...ous view test_view as select sum(x) as x_sum from test_table... ^ HINT: To include a relation in a continuous query, JOIN it with a stream.

This is the documentation:

Here’s the syntax for creating a continuous view:

CREATE CONTINUOUS VIEW name AS query

where query is a subset of a PostgreSQL SELECT statement:

SELECT [ DISTINCT [ ON ( expression [, ...] ) ] ]
    expression [ [ AS ] output_name ] [, ...]
    [ FROM from_item [, ...] ]
    [ WHERE condition ]
    [ GROUP BY expression [, ...] ]
    [ HAVING condition [, ...] ]
    [ WINDOW window_name AS ( window_definition ) [, ...] ]

where from_item can be one of:

stream_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
table_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
from_item [ NATURAL ] join_type from_item [ ON join_condition ]

According to this from_item could also be a table. Is the documentation wrong? If it is not possible to create a continuous view from the table is there a way to load current data from table to some stream.


Solution

  • Jeff from PipelineDB here.

    Is there a reason you would want to try and create a continuous view off of a regular table like this? Why not just create a regular view, or materialized view?

    PipelineDB is designed to continuously analyze infinite streams of raw data so that data doesn't need to be stored as regular tables and then processed in an ad hoc fashion, so this use case is exactly opposite of PipelineDB's intended purpose.