The WHERE clause of a SQL text: a boolean expression over predicates
(verified against InfluxDB 3 Core).
expr := term (OR term)*
term := factor (AND factor)*
factor := NOT factor | '(' expr ')' | predicateAND binds tighter than OR, as in SQL. The result is a conjunction list; OR
and NOT appear as nodes inside it, so a plain a AND b is still the flat
list every executor path already understands. A predicate is a comparison,
IN, BETWEEN, LIKE / ILIKE, a regular-expression match, IS [NOT] NULL or a bare boolean column; a $name is kept as a node for
InfluxElixir.Client.Local.SQLBind.
Summary
Types
A predicate: operator, left operand, right side.
A WHERE conjunction is a list of nodes: a predicate, an {:or, branches}
node whose branches are conjunctions, or a {:not, conjunction} node.
The comparison, set and pattern operators of a predicate.
A WHERE operand: a column name, or an arithmetic expression over columns
and literals (price <= med * 3).
Functions
Compiles a SQL regular expression for the match operator op (~, ~*,
!~, !~*); an invalid pattern is the optimizer's error.
A type error found in a time clause, kept as a clause for the planner to
raise when it types the query.
A LIKE (or, with case_insensitive, ILIKE) pattern as an anchored regular expression.
The operator that holds when the two sides of a comparison swap places.
Parses the WHERE ... clause (if any) out of the text after FROM <table>.
The SQL symbol of a comparison operator.
Types
@type clause() :: {op(), binary() | {:expr, InfluxElixir.Client.Local.SQLExpr.t()}, term()}
A predicate: operator, left operand, right side.
A WHERE conjunction is a list of nodes: a predicate, an {:or, branches}
node whose branches are conjunctions, or a {:not, conjunction} node.
@type op() ::
:eq
| :gt
| :lt
| :gte
| :lte
| :ne
| :in
| :not_in
| :is_null
| :is_not_null
| :between
| :not_between
| :like
| :not_like
| :regex
| :not_regex
| :time_type_error
The comparison, set and pattern operators of a predicate.
@type operand() :: binary() | {:expr, InfluxElixir.Client.Local.SQLExpr.t()}
A WHERE operand: a column name, or an arithmetic expression over columns
and literals (price <= med * 3).
Functions
@spec compile_regex(binary(), binary()) :: {:ok, Regex.t()} | {:error, InfluxElixir.Client.Local.SQLError.t()}
Compiles a SQL regular expression for the match operator op (~, ~*,
!~, !~*); an invalid pattern is the optimizer's error.
@spec deferred_clause(InfluxElixir.Client.Local.SQLError.t()) :: clause()
A type error found in a time clause, kept as a clause for the planner to
raise when it types the query.
A LIKE (or, with case_insensitive, ILIKE) pattern as an anchored regular expression.
The operator that holds when the two sides of a comparison swap places.
@spec nodes(binary()) :: {:ok, [node_t()]} | {:error, InfluxElixir.Client.Local.SQLError.t()}
Parses the WHERE ... clause (if any) out of the text after FROM <table>.
The SQL symbol of a comparison operator.