DuroDBMS API  1.2
Built-in read-only operators

Relational and related operators

OPERATOR RELATION

OPERATOR RELATION(t TUPLE { * }, ...) RETURNS RELATION { * };

Description

The relation selector.


OPERATOR is_empty

OPERATOR is_empty(RELATION { * }) RETURNS boolean;

Description

Checks if a table is empty.

Return value

TRUE if the relation-valued operand is empty, RDB_FALSE otherwise.


OPERATOR count

OPERATOR count(RELATION { * }) RETURNS integer;

Description

Counts the tuples in a table.

Return value

The cardinality of the relation-valued operand.


OPERATOR in

OPERATOR in (t TUPLE { * }, r RELATION { * }) RETURNS boolean;

Description

Checks if a table contains a given tuple.

Return value

TRUE if r contains t, RDB_FALSE otherwise.


OPERATOR subset_of

OPERATOR subset_of(r1 RELATION { * }, r2 RELATION { * }) RETURNS boolean;

Description

Checks if a table is a subset of another table.

Return value

TRUE if the r1 is a subset of r2, RDB_FALSE otherwise.


OPERATOR any

OPERATOR any(r RELATION { * }, attr boolean) RETURNS boolean;

Description

The any aggregate operator. For the semantics, see RDB_any().


OPERATOR all

OPERATOR all(r RELATION { * }, attr boolean) RETURNS boolean;

Description

The all aggregate operator. For the semantics, see RDB_all().


OPERATOR avg

OPERATOR avg(r RELATION { * }, attr integer) RETURNS float;

OPERATOR avg(r RELATION { * }, attr float) RETURNS float;

Description

The avg aggregate operator. For the semantics, see RDB_avg().


OPERATOR max

OPERATOR max(r RELATION { * }, attr integer) RETURNS integer;

OPERATOR max(r RELATION { * }, attr float) RETURNS float;

Description

The max aggregate operator. For the semantics, see RDB_max().


OPERATOR min

OPERATOR min(r RELATION { * }, attr integer) RETURNS integer;

OPERATOR min(r RELATION { * }, attr float) RETURNS float;

Description

The min aggregate operator. For the semantics, see RDB_min().


OPERATOR sum

OPERATOR SUM(r RELATION { * }, attr integer) RETURNS integer;

OPERATOR SUM(r RELATION { * }, attr float) RETURNS float;

Description

The SUM aggregate operator. For the semantics, see RDB_sum().


OPERATOR divide

OPERATOR divide(r1 RELATION { * }, r2 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };

Description

The relational three-argument (small) DIVIDE operator.


OPERATOR extend

OPERATOR extend(r RELATION { * }, attrexp ANY, attrname string, ...) RETURNS RELATION { * };


OPERATOR group

OPERATOR group(r RELATION { * }, attrname string ...) RETURNS RELATION { * };


OPERATOR intersect

OPERATOR intersect(r1 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };


OPERATOR join

OPERATOR join(r1 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };


OPERATOR minus

OPERATOR minus(r1 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };


OPERATOR project

OPERATOR project(r1 RELATION { * }, attrname string ...) RETURNS RELATION { * };


OPERATOR remove

OPERATOR remove(r RELATION { * }, attrname string ...) RETURNS RELATION { * };


OPERATOR rename

OPERATOR rename(r RELATION { * }, scr_attrname string, dst_attrname string ...) RETURNS RELATION { * };


OPERATOR ungroup

OPERATOR ungroup(r RELATION { * }, attrname string) RETURNS RELATION { * };


OPERATOR union

OPERATOR union(r1 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };


OPERATOR d_union

OPERATOR d_union(r1 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };


OPERATOR update

OPERATOR update(r1 RELATION { * }, dst_attrname string, src_expr ANY, ...) RETURNS RELATION { * };


OPERATOR unwrap

OPERATOR unwrap(attrname string, ...) RETURNS RELATION { * };


OPERATOR semijoin

OPERATOR semijoin(r1 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };


OPERATOR semiminus

OPERATOR semiminus(r1 RELATION { * }, r2 RELATION { * }) RETURNS RELATION { * };


OPERATOR summarize

OPERATOR summarize(r1 RELATION { * }, r2 RELATION { * }, expr ANY, attrname string, ...) RETURNS RELATION { * };


OPERATOR tclose

OPERATOR tclose(r RELATION { * }) RETURNS RELATION { * };

The transitive closure operator.


OPERATOR where

OPERATOR where(r RELATION { * }, b boolean) RETURNS RELATION { * };

The relational WHERE operator.


OPERATOR wrap

OPERATOR wrap(r RELATION { * }, src_attrs ARRAY OF string, dst_attr string ...) RETURNS RELATION { * };

The relational WRAP operator.


Comparison operators

OPERATOR =

OPERATOR = (ANY, ANY) RETURNS boolean;

The equality operator. Defined for every type. The arguments must be of the same type.

Returns

TRUE if the two arguments are equal, FALSE otherwise.


OPERATOR <>

OPERATOR <> (ANY, ANY) RETURNS boolean;

Description

The inequality operator. Defined for every type. The arguments must be of the same type.

Return value

TRUE if the two arguments are not equal, FALSE otherwise.


OPERATOR <

OPERATOR < (integer, integer) RETURNS boolean;

OPERATOR < (float, float) RETURNS boolean;

OPERATOR < (string, string) RETURNS boolean;

Description

The lower-than operator.

Return value

TRUE if the first argument is lower than the first. If the operands are strings, the strings will be compared using strcoll().


OPERATOR <=

OPERATOR <= (integer, integer) RETURNS boolean;

OPERATOR <= (float, float) RETURNS boolean;

OPERATOR <= (string, string) RETURNS boolean;

Description

The lower-than-or-equal operator.

Return value

TRUE if the first argument is lower than or equal to the second. If the operands are strings, the strings will be compared using strcoll().


OPERATOR >

OPERATOR > (integer, integer) RETURNS boolean;

OPERATOR > (float, float) RETURNS boolean;

OPERATOR > (string, string) RETURNS boolean;

Description

The greater-than operator.

Return value

TRUE if the first argument is greater than the first. If the operands are strings, the strings will be compared using strcoll().


OPERATOR >=

OPERATOR >= (integer, integer) RETURNS boolean;

OPERATOR >= (float, float) RETURNS boolean;

OPERATOR >= (string, string) RETURNS boolean;

Description

The greater-than-or-equal operator.

Return value

TRUE if the first argument is greater than or equal to the second. If the operands are strings, the strings will be compared using strcoll().


Logical operators

OPERATOR and

OPERATOR and (boolean, boolean) RETURNS boolean;

Description

The boolean AND operator.


OPERATOR OR

OPERATOR or (boolean, boolean) RETURNS boolean;

Description

The boolean OR operator.


OPERATOR xor

OPERATOR xor (boolean, boolean) RETURNS boolean;

Description

The boolean XOR operator.


OPERATOR not

OPERATOR not (boolean) RETURNS boolean;

Description

The boolean NOT operator.


OPERATOR if

OPERATOR IF (B boolean, V1 ANY, V2 ANY) RETURNS ANY;

Description

The IF-THEN-ELSE operator.

Return value

V1 if B is TRUE, V2 otherwise.


String operators

OPERATOR ||

OPERATOR || (s1 string, s2 string) RETURNS string;

Description

The string concatenation operator.

Return value

The result of the concatenation of the operands.


OPERATOR strlen

OPERATOR strlen (s string) RETURNS integer;

Description

The string length operator.

Return value

The length of s, in code points.


OPERATOR strlen_b

OPERATOR strlen_b (s string) RETURNS integer;

Description

The string length operator, returning the number of bytes.

Return value

The length of s, in bytes.


OPERATOR substr

OPERATOR substr(s string, start integer, length integer) RETURNS string;

Description

Extracts a substring.

Return value

The substring of s with length length starting at position start. length and start are measured in code points, according to the current encoding.

Errors

invalid_argument_error
start is negative, or start + length is greater than strlen(s).

OPERATOR substr_b

OPERATOR substr_b(s string, start integer, length integer) RETURNS string;

OPERATOR substr_b(s string, start integer) RETURNS string;

Description

Extracts a substring.

Return value

The substring of s with length length starting at position start. length and start are measured in bytes. If called with 2 arguments, the substring extends to the end of s.

Errors

invalid_argument_error
start or length are negative, or start + length is greater than strlen(s).

OPERATOR strfind_b

OPERATOR strfind_b (haystack string, needle string) RETURNS integer;

OPERATOR strfind_b (haystack string, needle string, int pos) RETURNS integer;

Description

Finds the first occurrence of the string needle in the string haystack. If called with 3 arguments, it finds the first occurrence after pos, where pos is a byte offset.

Return value

The position of the substring, in bytes, or -1 if the substring has not been found.


OPERATOR starts_with

OPERATOR starts_with (s string, prefix string) RETURNS boolean;

Description

Tests if string s starts with string prefix.

Return value

TRUE if s starts with prefix, FALSE otherwise


OPERATOR like

OPERATOR like (s string, pattern string) RETURNS boolean;

Description

Pattern matching operator. A period ('.') matches a single character; an asterisk ('*') matches zero or more characters.

Return value

TRUE if s matches pattern, RDB_FALSE otherwise.


OPERATOR regex_like

OPERATOR regex_like (s string, pattern string) RETURNS boolean;

Description

The regular expression matching operator.

Return value

TRUE if s matches pattern, RDB_FALSE otherwise.


OPERATOR format

OPERATOR format (format string, ...) RETURNS string;

Description

Generates a formatted string in the style of sprintf. The arguments passed after format must be of type string, integer, or float and must match the format argument.

Return value

The formatted string.


Type conversion operators

OPERATOR cast_as_integer

OPERATOR cast_as_integer (float) RETURNS integer;

OPERATOR cast_as_integer (string) RETURNS integer;

Description

Converts the operand to integer.

Return value

The operand, converted to integer.


OPERATOR cast_as_float

OPERATOR cast_as_float (integer) RETURNS float;

OPERATOR cast_as_float (string) RETURNS float;

Description

Converts the operand to float.

Return value

The operand, converted to float.


OPERATOR cast_as_string

OPERATOR cast_as_string (integer) RETURNS string;

OPERATOR cast_as_string (float) RETURNS string;

OPERATOR cast_as_string (binary) RETURNS string;

Description

Converts the operand to a string.

Return value

The operand, converted to string.


OPERATOR cast_as_binary

OPERATOR cast_as_string (string) RETURNS binary;

Description

Converts the operand to a binary, without a terminating nullbyte.

Return value

The operand, converted to string.


OPERATOR serialize

OPERATOR serialize (value ANY) RETURNS binary;

Description

Converts a value to a binary representation which includes the type.

Return value

The operand, converted to binary representation.


Arithmetic operators

OPERATOR +

OPERATOR + (integer, integer) RETURNS integer;

OPERATOR + (float, float) RETURNS float;

Description

The addition operator.

Return value

The sum of the two operands.


OPERATOR - (unary)

OPERATOR - (integer) RETURNS integer;

OPERATOR - (float) RETURNS float;

Description

The unary minus operator.

Return value

The operand, sign inverted.


OPERATOR - (binary)

OPERATOR - (integer, integer) RETURNS integer;

OPERATOR - (float, float) RETURNS float;

Description

The subtraction operator.

Return value

The difference of the two operands.


OPERATOR *

OPERATOR * (integer, integer) RETURNS integer;;

OPERATOR * (float, float) RETURNS float;

Description

The multiplication operator.

Return value

The product of the two operands.


OPERATOR /

OPERATOR / (integer, integer) RETURNS integer;

OPERATOR / (float, float) RETURNS float;

Description

The division operator.

Return value

The quotient of the operators.

Errors

INVALID_ARGUMENT_ERROR
The divisor is zero.

OPERATOR sqrt

OPERATOR sqrt(x float) RETURNS float;

The square root operator.


OPERATOR abs

OPERATOR abs(x integer) RETURNS integer;

OPERATOR abs(x float) RETURNS float;

The abs(absolute value) operator.


OPERATOR sin

OPERATOR sin (x float) RETURNS float;

The sine operator.


OPERATOR cos

OPERATOR cos(x float) RETURNS float;

The cosine operator.


OPERATOR atan

OPERATOR atan(x float) RETURNS float;

The arc tangent operator.


OPERATOR atan2

OPERATOR atan2(y float, x float) RETURNS float;

The atan2 operator.


OPERATOR power

OPERATOR power(b float, x float) RETURNS float;

The power operator.


OPERATOR

OPERATOR exp(x float) RETURNS float;

The exponential function operator.


OPERATOR

OPERATOR ln(x float) RETURNS float;

The natural logarithm operator.

OPERATOR

OPERATOR log(x float) RETURNS float;

The base 10 logarithm operator.


Tuple operators

OPERATOR TUPLE

OPERATOR TUPLE(ATTRNAME string, ATTRVAL ANY, ...) RETURNS TUPLE { * };

Description

The tuple selector.


OPERATOR to_tuple

OPERATOR to_tuple(r RELATION { * }) RETURNS TUPLE { * };

Description

Extracts a single tuple from a relation.


Array operators

OPERATOR array

OPERATOR array(ANY, ...) RETURNS ARRAY;

Description

The array selector.


OPERATOR length

OPERATOR length (ARRAY) RETURNS integer;

Description

The array length operator.

Return value

The length of the operand.


OPERATOR index_of

OPERATOR index_of (arr ARRAY, data ANY) RETURNS integer;

Description

Returns the index of the first occurrence of data in the array ARR.

Return value

The index, or -1 if data does not appear in the array.