barrel_bql_ast (barrel_docdb v1.1.1)

View Source

BQL AST shapes shared by the parser, the lowering pass and their consumers. Locations are {Line, Column} and sit on every node that can fail validation.

Summary

Types

ast/0

-type ast() ::
          #{type := select,
            select := star | [projection()],
            from := from(),
            where := expr() | undefined,
            order_by := [order_item()],
            limit := undefined | {integer, loc(), non_neg_integer()},
            offset := undefined | {integer, loc(), non_neg_integer()},
            subscribe := boolean()}.

expr/0

-type expr() ::
          {'and', loc(), expr(), expr()} |
          {'or', loc(), expr(), expr()} |
          {'not', loc(), expr()} |
          {cmp, loc(), '=' | '!=' | '<' | '<=' | '>' | '>=', operand(), operand()} |
          {is_null, loc(), operand(), Negated :: boolean()} |
          {is_missing, loc(), operand(), Negated :: boolean()} |
          {in, loc(), operand(), [literal()], Negated :: boolean()} |
          {like, loc(), operand(), binary(), Negated :: boolean()} |
          {between, loc(), operand(), operand(), operand(), Negated :: boolean()} |
          {contains, loc(), path(), literal()}.

fn_arg/0

-type fn_arg() :: {pos, operand()} | {named, binary(), operand()}.

from/0

-type from() :: #{source := source(), alias := binary() | undefined, unnest := undefined | unnest()}.

literal/0

-type literal() :: {lit, loc(), binary() | number() | boolean() | null}.

loc/0

-type loc() :: {pos_integer(), pos_integer()}.

operand/0

-type operand() :: path() | literal() | {param, loc(), binary()}.

order_item/0

-type order_item() :: {path(), asc | desc}.

path/0

-type path() :: {path, loc(), [path_component()]}.

path_component/0

-type path_component() :: {key, binary()} | {index, non_neg_integer()} | wildcard.

projection/0

-type projection() :: #{expr := path(), as := binary() | undefined, loc := loc()}.

source/0

-type source() :: {collection, loc(), binary()} | {table_fn, loc(), binary(), [fn_arg()]}.

unnest/0

-type unnest() :: #{path := path(), alias := binary(), loc := loc()}.