InfluxElixir.Client.Local.Format (InfluxElixir v0.1.35)

Copy Markdown View Source

Answers a query's format: option for InfluxElixir.Client.Local as Client.HTTP answers it from InfluxDB 3 (verified against Core):

  • :json / :jsonl (the default) — the rows as they are
  • :csv — the rows as the engine's CSV parses: every value a string, rendered as the engine renders it (1.5 → "1.5", 1.0e16 → "1e16", true → "true"), an empty value absent like a null one; timestamps stay DateTimes. The engine cannot write a nested value (array_agg, a selector_* struct) as CSV: it has sent 200 and closes the connection, so the answer is the same {:connection_error, %Mint.TransportError{reason: :closed}}
  • :parquet — refused by name: the double holds no Parquet writer
  • :pretty / :json_lines and their string forms — the engine accepts them but the client cannot parse them: {:unsupported_format, format}
  • anything else — the engine's 400 for an unknown variant

The engine reads format with the request, before it plans the query: an unknown format is its 400 whatever the query, as is the refusal of :parquet here; the others are answered from the query's result.

Summary

Functions

Runs the query (run returns {:ok, rows} or an error) and answers in format, or with the error Client.HTTP returns for that format.

A float as the engine's CSV writes it: positional notation, with .0 when there is no fraction, for 1.0e-5 <= |x| < 1.0e16; otherwise the shortest digits with an exponent and no .0 (1e16, 1.5e-7, 5e-324). Erlang's :short renders 1.0e15 and 1.0e-5 instead.

Functions

answer(format, run)

@spec answer(term(), (-> {:ok, [map()]} | {:error, term()})) ::
  {:ok, [map()]} | {:error, term()}

Runs the query (run returns {:ok, rows} or an error) and answers in format, or with the error Client.HTTP returns for that format.

render_float(value)

@spec render_float(float()) :: binary()

A float as the engine's CSV writes it: positional notation, with .0 when there is no fraction, for 1.0e-5 <= |x| < 1.0e16; otherwise the shortest digits with an exponent and no .0 (1e16, 1.5e-7, 5e-324). Erlang's :short renders 1.0e15 and 1.0e-5 instead.