Arithmetic Expressions

The standard arithmetic expressions are supported for numerical values:

select 3+2; -- returns 5
select 3-2; -- returns 1
select 3*2; -- returns 6
select 3/2; -- returns 1
select 3::decimal(1,0)/2; -- returns 1.5000000000000000000
select 3%2; -- returns 1 (modulo/remainder)

A subset is also supported for dates/intervals:

select '2023-07-18'::date + interval '5 day'; -- returns 2023-07-23
select '2023-07-18'::date - interval '5 day'; -- returns 2023-07-13


Values can be compared using the standard comparison operations =,!= or <>,<, >, <=, >=. In addition the following operations can be used to compare values:

x between y and z -- x>=y and x<=z
x not between y and z -- x<y or x>z
x in (1,2,3,4) -- returns true if x is one of 1,2,3,4
x is null -- true if x is null, false otherwise
x is not null -- false if x is null, true otherwise

Boolean Expressions

and, or, and not can be used as expected (including three-valued logic).

select null and false; --returns false
select null and true; --returns null
select null or true; --returns true
select null or false; --returns null
select not true; -- returns false


Values can be casted to a different type using one of the two cast constructs:

select cast(1.2 as string);
select '1.2'::float(32);

Note that the exact behavior depends on the source and destination types.

Case statement

The case statement can be used to implement switches based on a condition:

select x, case when x>42 then x/2 else 0 end from t; -- simple ternary expression: x>42?x/2:0
select x, case when x=1 then 10 when x=2 then 20 else 0 end from t; -- chained if ... elseif ... else
select x, case x when 1 then 10 when 2 then 20 end from integers; -- switch x case 1: ...


Coalesce returns the first non-null argument:

select coalesce(null,1); -- returns 1

Sub Queries

(Correlated) sub-queries are supported in the select and where clauses. The following kinds of sub-queries are supported:

(select ...) -- can return at most one value
exists(select ...) -- checks if any row is returned
not exists(select ...) -- checks that no row is returned
x in(select y from ...) -- is x in the returned values
x not in (select y from ...) -- is x not contained in the returned values
x = all(select y from ...) -- true if every y has the value of x
x = any(select y from ...) -- true if any y value has the value of x


select 'a' || 'b'; -- string concatenation -> 'ab'
select 'hello world' like 'hello %'; -- pattern matching -> true

Scalar Functions

Currently only few built-in functions are supported as others simply weren’t necessary until now.

date_partextract a part of a datedate_part('year','2023-07-11')2023
substringsubstring of stringsubstring('hello world',2,5)"ello"
absabsolute value of numerabs(-1.5)1.5
uppertransform string to upper caseupper('abc'::string)"ABC"
roundfound numer to number of digitsround(1.0006,3)1.0010
hashfast hash functionhash(42)539517765266996231