userver: clickhouse_io
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
clickhouse_io

uClickHouse driver doesn't expose underlying ClickHouse types and only provides a way to convert results to strongly-typed structs/containers (see storages::clickhouse::ExecutionResult).

As naive mapping is ambiguous for some types, namely for chrono and string, explicit mapping is required by the driver - explicit specialization of CppToClickhouse template.

Supported Clickhouse types:

Example usage:

namespace {
struct Data final {
std::vector<uint64_t> numbers;
std::vector<std::string> strings;
std::vector<uint64_t> other_numbers;
std::vector<std::chrono::system_clock::time_point> tps;
};
struct RowData final {
uint64_t number;
std::string string;
uint64_t other_number;
std::chrono::system_clock::time_point tp;
};
} // namespace
template <>
struct CppToClickhouse<Data> final {
using mapped_type =
std::tuple<columns::UInt64Column, columns::StringColumn,
columns::UInt64Column, columns::DateTime64ColumnNano>;
};
template <>
struct CppToClickhouse<RowData> final {
using mapped_type =
std::tuple<columns::UInt64Column, columns::StringColumn,
columns::UInt64Column, columns::DateTime64ColumnNano>;
};
} // namespace storages::clickhouse::io