InfluxElixir.Client.Local.SQLPredicates (InfluxElixir v0.1.40)

Copy Markdown View Source

Flattens a parsed WHERE into its conjuncts, pushing a NOT in as the engine's optimizer does, for the modules that reason about what a filter leaves (InfluxElixir.Client.Local.SQLBounds for a numeric column, InfluxElixir.Client.Local.SQLRange for time).

The structure is the same for both and the leaves differ, so the caller gives flatten/3 what to put for each kind of leaf:

  • :never — a constant false ({:or, []}, or the negation of an empty conjunction)
  • :opaque — a function from what hides its conjuncts (an OR, the negation of several conjuncts) to the leaf for it
  • :clause — a function from a predicate and whether a NOT is pushed into it to the leaves it contributes

Summary

Types

What a caller makes of each kind of leaf.

Functions

The leaves of a conjunction. negated says that a NOT has been pushed in front of it.

Whether the operator has a negation.

The operator that holds when the predicate is negated, or the operator itself when it has no negation here.

Types

leaves()

@type leaves() :: %{
  never: term(),
  opaque: (term() -> term()),
  clause: (InfluxElixir.Client.Local.SQLParser.where_clause(), boolean() ->
             [term()])
}

What a caller makes of each kind of leaf.

Functions

flatten(nodes, bool, leaves)

The leaves of a conjunction. negated says that a NOT has been pushed in front of it.

negatable?(op)

@spec negatable?(atom()) :: boolean()

Whether the operator has a negation.

negate_op(op)

@spec negate_op(atom()) :: atom()

The operator that holds when the predicate is negated, or the operator itself when it has no negation here.