ChDriver.Types.Registry (ch_driver v0.2.0)

Copy Markdown

The scalar/fixed-width column type codec table, plus the primitive wire readers it's built on.

Covers ClickHouse's fixed-width integer and float types, String, DateTime, Enum8/Enum16, UUID, IPv4, and IPv6. Adding a new scalar type is a one-line addition to column_codec/1.

UUID values decode to their standard hyphenated text form. IPv4/IPv6 decode to dotted-quad / colon-hex text. DateTime decodes to a UTC DateTime.t(). Date decodes to a Date.t().

Summary

Functions

Looks up the fixed-width/string codec for a scalar ClickHouse type name. Returns {:fixed, byte_size, unpack_fun}, :string, or :unsupported.

Reads num_rows fixed-width byte_size-byte chunks from binary, running each through unpack (e.g. fn <<v::unsigned-little-32>> -> v end). Returns {:ok, values, rest} or {:incomplete, binary} if fewer than num_rows * byte_size bytes are available.

Reads remaining ClickHouse String values (varint length prefix + bytes) from binary. Returns {:ok, values, rest} or {:incomplete, binary}.

Functions

column_codec(arg1)

Looks up the fixed-width/string codec for a scalar ClickHouse type name. Returns {:fixed, byte_size, unpack_fun}, :string, or :unsupported.

decode_fixed_width(binary, num_rows, byte_size, unpack)

Reads num_rows fixed-width byte_size-byte chunks from binary, running each through unpack (e.g. fn <<v::unsigned-little-32>> -> v end). Returns {:ok, values, rest} or {:incomplete, binary} if fewer than num_rows * byte_size bytes are available.

decode_strings(binary, remaining, acc)

Reads remaining ClickHouse String values (varint length prefix + bytes) from binary. Returns {:ok, values, rest} or {:incomplete, binary}.