ChDriver. Types
(ch_driver v0.1.1)
Copy Markdown
Parses ClickHouse column type strings, e.g. "Nullable(String)" or
"Map(String, Decimal(10, 2))", into their component parts.
Pure string parsing — no wire decoding happens here. See
ChDriver.Protocol.Block.Wrappers for how the parsed types drive actual
column decoding.
Supports Nullable(T), Array(T), Map(K, V), LowCardinality(T),
Decimal(P, S) (and its Decimal32/64/128/256(S) aliases), and
FixedString(N). Tuple(...) isn't supported as a standalone column
type — only as Map's internal representation.
Summary
Functions
Parses ClickHouse's Array(T) wrapper syntax, returning the inner type
string.
Parses Decimal(P, S) and the Decimal32(S)/Decimal64(S)/
Decimal128(S)/Decimal256(S) fixed-precision aliases, returning
{:ok, precision, scale}.
Parses ClickHouse's FixedString(N) type, returning {:ok, n}.
Parses ClickHouse's LowCardinality(T) wrapper syntax, returning the
inner type string.
Parses ClickHouse's Map(K, V) wrapper syntax, returning {:ok, key_type, value_type}. Splits on the top-level comma only (tracking
paren depth so e.g. Map(String, Decimal(10, 2)) isn't split on the
inner comma).
Parses ClickHouse's Nullable(T) wrapper syntax, returning the inner
type string.
Splits inner on its top-level comma(s) only, tracking paren depth so a
parameterized inner type's own comma (e.g. the Decimal(10, 2) inside
Map(String, Decimal(10, 2))) is never mistaken for the wrapper's own
separator. Returns the list of (untrimmed) parts, or :error if the
parens are unbalanced.
Strips a Prefix(...) wrapper down to its inner contents, given the
exact "Prefix(" (including the opening paren) to match against. Not a
general parenthesis-balancer -- just strips the given prefix and the
trailing ) -- but that's sufficient even for a parameterized inner
type like Nullable(DateTime(3)), since the outer ) is always the
last byte of the whole type string.
Functions
Parses ClickHouse's Array(T) wrapper syntax, returning the inner type
string.
Parses Decimal(P, S) and the Decimal32(S)/Decimal64(S)/
Decimal128(S)/Decimal256(S) fixed-precision aliases, returning
{:ok, precision, scale}.
Parses ClickHouse's FixedString(N) type, returning {:ok, n}.
Parses ClickHouse's LowCardinality(T) wrapper syntax, returning the
inner type string.
Parses ClickHouse's Map(K, V) wrapper syntax, returning {:ok, key_type, value_type}. Splits on the top-level comma only (tracking
paren depth so e.g. Map(String, Decimal(10, 2)) isn't split on the
inner comma).
Parses ClickHouse's Nullable(T) wrapper syntax, returning the inner
type string.
Splits inner on its top-level comma(s) only, tracking paren depth so a
parameterized inner type's own comma (e.g. the Decimal(10, 2) inside
Map(String, Decimal(10, 2))) is never mistaken for the wrapper's own
separator. Returns the list of (untrimmed) parts, or :error if the
parens are unbalanced.
Strips a Prefix(...) wrapper down to its inner contents, given the
exact "Prefix(" (including the opening paren) to match against. Not a
general parenthesis-balancer -- just strips the given prefix and the
trailing ) -- but that's sufficient even for a parameterized inner
type like Nullable(DateTime(3)), since the outer ) is always the
last byte of the whole type string.