View Source ClickHouse (ClickHouse v0.30.0)

A ClickHouse client.

This currently represents an early work in progress.

Link to this section Summary

Types

A ClickHouse client.

The data types available.

A list of data types.

Various representations of ClickHouse-related errors.

Parameters used with queries.

A query statement.

Functions

Returns a specification to start this module under a supervisor.

Executes a query using a ClickHouse client.

Prepares a query for a ClickHouse client.

Prepares and executes a query using a ClickHouse client.

Starts a ClickHouse client.

Creates a new query stream using a ClickHouse client.

Link to this section Types

@type client() :: atom() | ClickHouse.Client.t()

A ClickHouse client.

@type data_type() ::
  :i64
  | :i32
  | :i16
  | :i8
  | :u64
  | :u32
  | :u16
  | :u8
  | :f64
  | :f32
  | :string
  | :uuid
  | :date
  | :datetime
  | {:datetime64, integer()}
  | {:fixed_string, integer()}
  | {:enum8, %{required(String.t() | atom()) => integer()}}
  | {:enum16, %{required(String.t() | atom()) => integer()}}
  | {:array, data_type()}
  | {:low_cardinality, data_type()}
  | {:nullable, data_type()}
  | {{:simple_aggregate_function, atom()}, data_type()}

The data types available.

@type data_types() :: [data_type()]

A list of data types.

Various representations of ClickHouse-related errors.

@type params() :: list() | {data_types(), list()}

Parameters used with queries.

Optional data types can be provided in a tuple format.

@type start_option() ::
  {:name, atom()}
  | {:interface, ClickHouse.Interface.t()}
  | {:formats, [ClickHouse.Format.t()]}

Options used for child_spec/1 and start_link/1

@type statement() :: binary() | struct()

A query statement.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

execute(client, query, opts \\ [])

View Source
@spec execute(client(), ClickHouse.Query.t(), opts :: keyword()) ::
  {:ok, ClickHouse.Result.t()} | {:error, error()}

Executes a query using a ClickHouse client.

Link to this function

prepare(client, statement, params \\ [])

View Source
@spec prepare(client(), statement(), params()) :: ClickHouse.Query.t()

Prepares a query for a ClickHouse client.

Link to this function

query(client, statement, params \\ [], opts \\ [])

View Source
@spec query(client(), statement(), params(), keyword()) ::
  {:ok, ClickHouse.Result.t()} | {:error, error()}

Prepares and executes a query using a ClickHouse client.

@spec start_link([start_option()]) :: Supervisor.on_start()

Starts a ClickHouse client.

options

Options

  • :name - Required. The name of the client. Defaults to :default.
  • :interface - Required. The network interface to use for queries. Defaults to ClickHouse.Interface.HTTP.
  • :formats - Required. A list of formats available for encoding/decoding. Defaults to [ClickHouse.Format.JSONCompactEachRow, ClickHouse.Format.RowBinary, ClickHouse.Format.TSV, ClickHouse.Format.TSVWithNames, ClickHouse.Format.TSVWithNamesAndTypes, ClickHouse.Format.Values].

extra-options

Extra Options

Any additional options passed will be given to the client interface.

Link to this function

stream!(client, query, params \\ [], opts \\ [])

View Source
@spec stream!(client(), statement(), params(), opts :: keyword()) ::
  ClickHouse.Stream.t()

Creates a new query stream using a ClickHouse client.