Skip to main content

Your first SQL program

Feldera only supports two kinds of SQL Data Definition Language (DDL) statements: table definitions, and view definitions. Each table definition becomes an input, and each view definition becomes an output. Here is an example program:

CREATE TABLE person
(
name VARCHAR,
age INT,
present BOOLEAN
);
CREATE MATERIALIZED VIEW adult AS SELECT person.name, person.age FROM person WHERE person.age > 18;

Statements need to be separated by semicolons.

Incremental view maintenance​

Feldera is optimized for performing incremental view maintenance. In consequence, Feldera programs in SQL are expressed as VIEWS, or standing queries. A view is a virtual table that is formed by a query on other tables or views.

For example, the following query defines a view:

CREATE MATERIALIZED VIEW adult AS SELECT person.name FROM person WHERE person.age > 18

In order to interpret this query the compiler needs to have been given a definition of table (or view) Person. The table Person must be defined using a SQL DDL statement, e.g.:

CREATE TABLE person
(
name VARCHAR,
age INT,
present BOOLEAN
)