ChDriver.Protocol.Block.Wrappers (ch_driver v0.2.0)

Copy Markdown

Decoders for ClickHouse's wrapper and compound column types: Nullable(T), Array(T), Map(K, V), LowCardinality(T), and Decimal(P, S).

Dispatched from ChDriver.Protocol.NativeBlock's decode_column_data/3, which these functions recurse back into for their inner type(s) — that's what lets deeply nested types like Array(Nullable(String)) or Map(String, Array(UInt32)) decode correctly without any special-casing.

Map(K, V) values decode to plain Elixir maps; Array(T) and LowCardinality(T) decode to lists; Nullable(T) decodes to the inner value or nil; Decimal(P, S) decodes to a Decimal.t(). See ARCHITECTURE.md for the wire-level byte layouts.

Summary

Functions

Splits values (the flattened element array) back into per-row lists using Array(T)'s cumulative offsets, e.g. values = [1, 2, 3, 4, 5] and offsets = [2, 2, 5] (row 0 has 2 elements, row 1 has 0, row 2 has

Functions

split_by_offsets(values, offsets)

Splits values (the flattened element array) back into per-row lists using Array(T)'s cumulative offsets, e.g. values = [1, 2, 3, 4, 5] and offsets = [2, 2, 5] (row 0 has 2 elements, row 1 has 0, row 2 has

  1. splits into [[1, 2], [], [3, 4, 5]].