Documentation home

DuroDBMS expression syntax

The language for DuroDBMS expressions is a dialect of Tutorial D, as defined in TTM, third edition and Database Explorations, with a number of differences. The most important are:

  1. DuroDBMS uses a dot ('.') operator for tuple attribute access (FROM is supported too, but only for read acess) and for specifying a package to which an identifier refers.
  2. DuroDBMS supports LIKE and REGEX_LIKE operators for pattern matching.
  3. DuroDBMS uses the keywords SUBSET_OF for the subset operator and IN for the element-of operator.
  4. DuroDBMS supports both single ("'") and double quotes ('"') as delimiters in string literals.

DuroDBMS expression syntax (EBNF notation)

expression = project | where | rename | dyadic_relation_op_inv 
    | extend | update | summarize | divideby
    | wrap | unwrap | group | ungroup
    | expression OR expression
    | expression AND expression
    | expression XOR expression
    | NOT expression
    | rel_expression
    | '+' expression | '-' expression
    | expression '+' expression
    | expression '-' expression
    | expression '||' expression
    | expression '*' expression
    | expression '/' expression
    | expression '%' expression
    | var_expression
    | literal
    | count_inv
    | agg_op_inv
    | '(' expression ')'
    | id FROM expression
    | TUPLE FROM expression
    | ifthenelse
    | with.
var_expression = [expression '.'] id
    | ro_op_inv
    | array_subscript_inv.

ro_op_inv = [expression '.'] id '(' [expression {',' expression}] ')'.

array_subscript_inv = expression '[' expression ']'. 

project = expression '{' [ALL BUT] [id {',' id}] '}'.

where = expression WHERE expression.

rename = expression RENAME '{' [id AS id {',' id AS id}] '}'.

dyadic_relation_op_inv = expression UNION expression
        | expression D_UNION expression
        | expression INTERSECT expression
        | expression MINUS expression
        | expression SEMIMINUS expression
        | expression JOIN expression
        | expression SEMIJOIN expression
        | expression MATCHING expression
        | expression NOT MATCHING expression.

extend = EXTEND expression ':' '{' [id ':=' expression {',' id ':=' expression}] '}'.

update = UPDATE expression ':' '{' [id ':=' expression {',' id ':=' expression}] '}'.

summarize = SUMMARIZE expression PER expression
           ':' '{' [id ':=' expression {',' id ':=' expression}] '}'.

divideby = expression DIVIDEBY expression PER expression.

summary = COUNT '(' ')' | agg_op_name '(' expression ')'.

agg_op_name = SUM | AVG | MAX | MIN | ALL | AND | ANY | OR.

wrap = expression WRAP '(' [wrapping {',' wrapping}] ')'.

wrapping = '{' [id {',' id}] '}' AS id.

unwrap = expression UNWRAP '(' [id {',' id}] ')'.

group  = expression GROUP '{' [id {',' id}] '}' AS id.

ungroup = expression UNGROUP id.

with = WITH '(' [id ':=' expression {',' id ':=' expression}] ')' ':' expression.

rel_expression = expression | expression '=' expression
        | expression '<>' expression
        | expression '!=' expression
        | expression '>=' expression
        | expression '<=' expression
        | expression '>' expression
        | expression '<' expression
        | expression SUBSET_OF expression
        | expression IN expression
        | expression LIKE expression
        | expression REGEX_LIKE expression.

ifthenelse = IF expression THEN expression ELSE expression.

count_inv = COUNT '(' expression ')'.

agg_op_inv = agg_op_name '(' expression [',' expression] ')'.

literal = string | integer | decimal | float | binary | TRUE | FALSE
        | RELATION '{' [id type {',' id type}] '}' '{' [expression {',' expression}] '}'
        | RELATION '{' expression {',' expression} '}'
        | TABLE_DEE | TABLE_DUM
        | TUPLE '{' [id expression {',' id expression}] '}'
        | ARRAY type '(' [expression {',' expression}] ')'
        | ARRAY '(' expression {',' expression} ')'.
type = qualified_id
        | TUPLE '{' [id type {',' id type}] '}'
        | TUPLE '{' [id type {',' id type} ','] '*' '}'
        | RELATION '{' [id type {',' id type}] '}'
        | ARRAY type
        | SAME_TYPE_AS '(' expression ')'
        | TUPLE SAME_HEADING_AS '(' expression ')'
        | RELATION SAME_HEADING_AS '(' expression ')'.
qualified_id = {id '.'} id.
string = '"'{esc_char}'"' | "'"{character}"'".

esc_char = character | '\"' | '\\' | '\n' | '\r' | '\t'.

integer = digit{digit}.

decimal = digit{digit}'.'digit{digit}.

float = digit{digit}'.'digit{digit}('E' | 'e')digit{digit} | NaN.

binary = "X'"{hex_digit hex_digit}"'"
id = letter{letter | digit | '_' | '#'}["'"]
     | "`"letter{letter | digit | '_' | '#'}["'"]"`".