Hello, World!
FeatureQL looks like SQL but works differently: you define features (named values) instead of selecting from tables. This page walks through the basics with interactive examples.
The blocks are live FeatureQL — click Run. -- starts a line comment; /* … */ is a block comment. An unnamed result column may show as ?; give it a name with := as in the next example.
Returning values
The simplest query returns a literal value, just like SELECT 1 in SQL:
RETURN
'Hello, World !'
;| ?_0 VARCHAR |
|---|
| Hello, World ! |
Naming features
Give a name to a value and it becomes a feature — a reusable building block you can reference elsewhere in the query or persist for use across queries:
RETURN
greeting := 'Hello, World !',
three := 3
;| GREETING VARCHAR | THREE BIGINT |
|---|---|
| Hello, World ! | 3 |
Unquoted feature names cannot be AND, OR, NOT, IS, NULL, TRUE, or FALSE. Clause words such as ORDER, RETURN, and DEFINE are fine unquoted.
Computing values
Features can be computed from operators and functions. Here, string concatenation is shown two ways — the || operator and the CONCAT() function — both produce the same result:
RETURN
'Hello, ' || 'World' || '!', -- Using the operator concat
CONCAT('Hello, ', 'World', '!')
;| ?_0 VARCHAR | ?_1 VARCHAR |
|---|---|
| Hello, World! | Hello, World! |
Referencing other features
Features can reference other features defined in the same query. No CTEs, no subqueries — just name a feature and use it. FeatureQL resolves the dependency graph automatically:
RETURN
subject := 'World',
salutation := 'Hello, ' || subject || '!',
n := 1,
n_plus_2 := n + 2
;| SUBJECT VARCHAR | SALUTATION VARCHAR | N BIGINT | N_PLUS_2 BIGINT |
|---|---|---|---|
| World | Hello, World! | 1 | 3 |
Notice that SALUTATION references SUBJECT, and N_PLUS_2 references N. The order you write them doesn't matter — FeatureQL figures out the evaluation order.
Case insensitivity
Keywords, feature names, and function names are all case insensitive:
RETURN
'World' As SuBjEcT,
'Hello, ' || sUbJeCt || '!',
n + 2,
1 aS n| SUBJECT VARCHAR | ?_1 VARCHAR | ?_2 BIGINT | N BIGINT |
|---|---|---|---|
| World | Hello, World! | 3 | 1 |
As, sUbJeCt, aS — it all works. Use whatever casing convention your team prefers. RETURN and DEFINE are the clause words; SELECT and WITH are SQL.
Next
Types — families, inference, and casts.