InfluxElixir.Query.ResponseParser (InfluxElixir v0.1.21)

Copy Markdown View Source

Parses InfluxDB query responses in JSON, JSONL, and Flux annotated CSV formats, and passes Parquet bodies through untouched.

Type Coercion

  • time, _time, _start, _stop RFC3339 strings → DateTime.t()
  • JSON / JSONL numbers and booleans keep the types Jason decodes
  • CSV cells are typed from the Flux #datatype annotation row when the query requested one (double, long, unsignedLong, boolean, dateTime:RFC3339[Nano]); without it every cell stays a string

Summary

Functions

Coerces known value types in a row map.

Parses a response body based on the specified format.

Functions

coerce_types(row)

@spec coerce_types(map()) :: map()

Coerces known value types in a row map.

Converts RFC3339 strings under time, _time, _start and _stop to DateTime; leaves everything else as-is.

parse(body, format \\ :json)

@spec parse(binary(), atom()) :: {:ok, [map()] | binary()} | {:error, term()}

Parses a response body based on the specified format.

Parameters

  • body - response body binary
  • format - one of :json, :jsonl, :csv, :parquet

Returns

  • {:ok, [map()]} — list of row maps ({:ok, binary()} for :parquet)
  • {:error, reason} — parse failure