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

Copy Markdown View Source

The schema errors of a SQL query for InfluxElixir.Client.Local: a column the query names that no row has — in SELECT, an aggregate, WHERE, GROUP BY, ORDER BY or DISTINCT — is the engine's schema error ("No field named prod. Valid fields are ..."), not an empty or unsorted result. The usual cause is a typo or a forgotten pair of quotes around a string literal. With no rows the schema is unknown, so nothing is checked.

A relation is one table or CTE of a FROM, with the name its columns are qualified by in the engine's "Valid fields" list.

Summary

Types

The clause a reference stands in.

A stored point, as InfluxElixir.Client.Local keeps it.

One relation of a FROM: the name its columns are qualified with, its points, and its columns in order when it is a CTE (a table's are its points', sorted).

Functions

:ok, or the engine's schema error for the first column the query names that is not there.

Every source column the query refers to, with the clause it stands in, in the order the engine resolves the clauses. ORDER BY may name an output alias instead, which is not a source column.

The columns an expression, or a plan item over expressions, reads.

The columns a query's rows are made of, whether or not any row has a value for them: a column that is null in every row is still in the schema the next query reads. nil when a relation's columns are not known.

Every tag and field name any of the points has.

A source (its points and, for a CTE, its columns) as the relation known by qualifier.

The query with the positions in a SELECT *'s ORDER BY replaced by the columns they name, or the engine's planning error for a position outside them (ORDER BY 0 and a position past the last column; verified).

Whether the query selects *.

Whether a relation's columns cannot be known: a table with no rows.

The columns a WHERE reads.

Types

clause()

@type clause() :: :where | :select | :order | :group | :on

The clause a reference stands in.

point()

A stored point, as InfluxElixir.Client.Local keeps it.

relation()

@type relation() :: %{
  qualifier: binary(),
  points: [point()],
  columns: [binary()] | nil
}

One relation of a FROM: the name its columns are qualified with, its points, and its columns in order when it is a CTE (a table's are its points', sorted).

Functions

check(relations, query)

@spec check([relation()], InfluxElixir.Client.Local.SQLParser.parsed_query()) ::
  :ok | {:error, term()}

:ok, or the engine's schema error for the first column the query names that is not there.

clause_refs(query)

Every source column the query refers to, with the clause it stands in, in the order the engine resolves the clauses. ORDER BY may name an output alias instead, which is not a source column.

expr_fields(items)

The columns an expression, or a plan item over expressions, reads.

output_columns(arg1, relations)

@spec output_columns(InfluxElixir.Client.Local.SQLParser.parsed_query(), [relation()]) ::
  [binary()] | nil

The columns a query's rows are made of, whether or not any row has a value for them: a column that is null in every row is still in the schema the next query reads. nil when a relation's columns are not known.

point_columns(points)

@spec point_columns([point()]) :: MapSet.t(binary())

Every tag and field name any of the points has.

relation(qualifier, source)

@spec relation(binary(), %{points: [point()], columns: [binary()] | nil}) ::
  relation()

A source (its points and, for a CTE, its columns) as the relation known by qualifier.

resolve_ordinals(query, relations)

The query with the positions in a SELECT *'s ORDER BY replaced by the columns they name, or the engine's planning error for a position outside them (ORDER BY 0 and a position past the last column; verified).

star?(query)

Whether the query selects *.

unknown_schema?(arg1)

@spec unknown_schema?(relation()) :: boolean()

Whether a relation's columns cannot be known: a table with no rows.

where_refs(nodes)

The columns a WHERE reads.