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

Copy Markdown View Source

Executes a parsed SQL query for InfluxElixir.Client.Local.

Takes the InfluxElixir.Client.Local.SQLParser.parsed_query/0 the parser produced and a function that fetches a measurement's points, and returns rows in the shape InfluxDB 3's JSON responses have: string keys, time as a DateTime, null columns omitted. Every rule the double enforces about what the engine returns lives in the modules this one calls, in the order the engine meets them:

Storage, profiles and the other query languages stay in Client.Local.

Pure over the points it is given: no ETS, no connection state.

Summary

Types

Fetches a measurement's points, or :error when there is no such measurement.

Looks up a stored column's kind from its measurement and name: the iox::column_type::field::<type> the store registered, or nil.

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

Functions

Whether a point satisfies a parsed WHERE conjunction (also used by DELETE).

Runs a parsed query. fetch returns a measurement's points, or :error when the measurement does not exist; CTEs shadow it by name. params are the engine's values for the query's $name placeholders (see InfluxElixir.Client.QueryParams.engine_values/1). kinds tells an Int64 column from a UInt64 one, which the stored integers do not; a query that runs without it reads every integer column as Int64.

Runs the SQL that an InfluxQL query is written as. The engine's InfluxQL planner does not fail on a WHERE that leaves a numeric column no value (verified: it answers []), so that failure is not raised here.

Types

fetch()

@type fetch() :: (binary() -> {:ok, [point()]} | :error)

Fetches a measurement's points, or :error when there is no such measurement.

kinds()

@type kinds() :: (binary(), binary() -> binary() | nil)

Looks up a stored column's kind from its measurement and name: the iox::column_type::field::<type> the store registered, or nil.

point()

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

Functions

matches_all?(point, conjunction)

Whether a point satisfies a parsed WHERE conjunction (also used by DELETE).

run(query, fetch, params, kinds \\ nil)

@spec run(
  InfluxElixir.Client.Local.SQLParser.parsed_query(),
  fetch(),
  %{required(binary()) => term()},
  kinds() | nil
) :: [map()] | {:error, term()}

Runs a parsed query. fetch returns a measurement's points, or :error when the measurement does not exist; CTEs shadow it by name. params are the engine's values for the query's $name placeholders (see InfluxElixir.Client.QueryParams.engine_values/1). kinds tells an Int64 column from a UInt64 one, which the stored integers do not; a query that runs without it reads every integer column as Int64.

This is the engine's SQL: a WHERE that leaves a numeric column no value fails as it does there (see InfluxElixir.Client.Local.SQLBounds).

run_influxql(query, fetch)

@spec run_influxql(InfluxElixir.Client.Local.SQLParser.parsed_query(), fetch()) ::
  [map()] | {:error, term()}

Runs the SQL that an InfluxQL query is written as. The engine's InfluxQL planner does not fail on a WHERE that leaves a numeric column no value (verified: it answers []), so that failure is not raised here.