View Source Ch.Types (Ch v0.2.6)

Helpers to turn ClickHouse types into Elixir terms for easier processing.

Summary

Functions

Helper for Array(T) ClickHouse type

Helper for Bool ClickHouse type

Helper for Date32 ClickHouse type

Helper for Date ClickHouse type

Helper for DateTime64(precision) ClickHouse type

Helper for DateTime64(precision, timezone) ClickHouse type

Helper for DateTime ClickHouse type

Helper for DateTime(timezone) ClickHouse type

Helper for Decimal32(S) ClickHouse type

Helper for Decimal64(S) ClickHouse type

Helper for Decimal128(S) ClickHouse type

Helper for Decimal256(S) ClickHouse type

Helper for Decimal(P, S) ClickHouse type

Decodes a ClickHouse type into an intermediary Elixir term.

Encodes a type from Elixir atom / tuple to proper ClickHouse name.

Helper for Enum8 ClickHouse type

Helper for Enum16 ClickHouse type

Helper for Float32 ClickHouse type

Helper for Float64 ClickHouse type

Helper for FixedString(n) ClickHouse type

Helper for Int8 ClickHouse type

Helper for Int16 ClickHouse type

Helper for Int32 ClickHouse type

Helper for Int64 ClickHouse type

Helper for Int128 ClickHouse type

Helper for Int256 ClickHouse type

Helper for IPv4 ClickHouse type

Helper for IPv6 ClickHouse type

Helper for LowCardinality(T) ClickHouse type

Helper for Map(K, V) ClickHouse type

Helper for MultiPolygon ClickHouse type

Helper for Nothing ClickHouse type

Helper for Nullable(T) ClickHouse type

Helper for Point ClickHouse type

Helper for Polygon ClickHouse type

Helper for Ring ClickHouse type

Helper for SimpleAggregateFunction(name, type) ClickHouse type

Helper for String ClickHouse type

Helper for Tuple(T1, T2, ...) ClickHouse type

Helper for UInt8 ClickHouse type

Helper for UInt16 ClickHouse type

Helper for UInt32 ClickHouse type

Helper for UInt64 ClickHouse type

Helper for UInt128 ClickHouse type

Helper for UInt256 ClickHouse type

Helper for UUID ClickHouse type

Functions

Helper for Array(T) ClickHouse type:

iex> array(u64())
{:array, :u64}

iex> to_string(encode(array(u64())))
"Array(UInt64)"

iex> decode("Array(UInt64)")
array(u64())

Helper for Bool ClickHouse type:

iex> boolean()
:boolean

iex> encode(boolean())
"Bool"

iex> decode("Bool")
boolean()

Helper for Date32 ClickHouse type:

iex> date32()
:date32

iex> encode(date32())
"Date32"

iex> decode("Date32")
date32()

Helper for Date ClickHouse type:

iex> date()
:date

iex> encode(date())
"Date"

iex> decode("Date")
date()

Helper for DateTime64(precision) ClickHouse type:

iex> datetime64(3)
{:datetime64, 3}

iex> to_string(encode(datetime64(3)))
"DateTime64(3)"

iex> decode("DateTime64(3)")
datetime64(3)
Link to this function

datetime64(precision, timezone)

View Source

Helper for DateTime64(precision, timezone) ClickHouse type:

iex> datetime64(3, "UTC")
{:datetime64, 3, "UTC"}

iex> to_string(encode(datetime64(3, "UTC")))
"DateTime64(3, 'UTC')"

iex> decode("DateTime64(3, 'UTC')")
datetime64(3, "UTC")

Helper for DateTime ClickHouse type:

iex> datetime()
:datetime

iex> to_string(encode(datetime()))
"DateTime"

iex> decode("DateTime")
datetime()

Helper for DateTime(timezone) ClickHouse type:

iex> datetime("Europe/Vienna")
{:datetime, "Europe/Vienna"}

iex> to_string(encode(datetime("UTC")))
"DateTime('UTC')"

iex> decode("DateTime('UTC')")
datetime("UTC")

Helper for Decimal32(S) ClickHouse type:

iex> decimal32(4)
{:decimal32, 4}

iex> to_string(encode(decimal32(4)))
"Decimal(9, 4)"

iex> decode("Decimal32(4)")
{:decimal32, 4}

Helper for Decimal64(S) ClickHouse type:

iex> decimal64(4)
{:decimal64, 4}

iex> to_string(encode(decimal64(4)))
"Decimal(18, 4)"

iex> decode("Decimal64(4)")
{:decimal64, 4}

Helper for Decimal128(S) ClickHouse type:

iex> decimal128(4)
{:decimal128, 4}

iex> to_string(encode(decimal128(4)))
"Decimal(38, 4)"

iex> decode("Decimal128(4)")
{:decimal128, 4}

Helper for Decimal256(S) ClickHouse type:

iex> decimal256(4)
{:decimal256, 4}

iex> to_string(encode(decimal256(4)))
"Decimal(76, 4)"

iex> decode("Decimal256(4)")
{:decimal256, 4}
Link to this function

decimal(precision, scale)

View Source

Helper for Decimal(P, S) ClickHouse type:

iex> decimal(18, 4)
{:decimal, 18, 4}

iex> to_string(encode(decimal(18, 4)))
"Decimal(18, 4)"

iex> decode("Decimal(18, 4)")
decimal(18, 4)

Decodes a ClickHouse type into an intermediary Elixir term.

iex> decode("String")
:string

iex> decode("Array(String)")
{:array, :string}

iex> decode("Enum8('hello' = 1, 'world' = 2)")
{:enum8, [{"hello", 1}, {"world", 2}]}

iex> decode("Nullable(Decimal(18, 4))")
{:nullable, {:decimal, 18, 4}}

Encodes a type from Elixir atom / tuple to proper ClickHouse name.

iex> encode(:string)
"String"

iex> IO.iodata_to_binary(encode({:nullable, :i8}))
"Nullable(Int8)"

Helper for Enum8 ClickHouse type:

iex> enum8([{"hello", 1}, {"world", 2}])
{:enum8, [{"hello", 1}, {"world", 2}]}

iex> to_string(encode(enum8([{"hello", 1}, {"world", 2}])))
"Enum8('hello' = 1, 'world' = 2)"

iex> decode("Enum8('hello' = 1, 'world' = 2)")
enum8([{"hello", 1}, {"world", 2}])

Helper for Enum16 ClickHouse type:

iex> enum16([{"hello", 1}, {"world", 2}])
{:enum16, [{"hello", 1}, {"world", 2}]}

iex> to_string(encode(enum16([{"hello", 1}, {"world", 2}])))
"Enum16('hello' = 1, 'world' = 2)"

iex> decode("Enum16('hello' = 1, 'world' = 2)")
enum16([{"hello", 1}, {"world", 2}])

Helper for Float32 ClickHouse type:

iex> f32()
:f32

iex> encode(f32())
"Float32"

iex> decode("Float32")
f32()

Helper for Float64 ClickHouse type:

iex> f64()
:f64

iex> encode(f64())
"Float64"

iex> decode("Float64")
f64()

Helper for FixedString(n) ClickHouse type:

iex> fixed_string(3)
{:fixed_string, 3}

iex> to_string(encode(fixed_string(16)))
"FixedString(16)"

iex> decode("FixedString(16)")
fixed_string(16)

Helper for Int8 ClickHouse type:

iex> i8()
:i8

iex> encode(i8())
"Int8"

iex> decode("Int8")
i8()

Helper for Int16 ClickHouse type:

iex> i16()
:i16

iex> encode(i16())
"Int16"

iex> decode("Int16")
i16()

Helper for Int32 ClickHouse type:

iex> i32()
:i32

iex> encode(i32())
"Int32"

iex> decode("Int32")
i32()

Helper for Int64 ClickHouse type:

iex> i64()
:i64

iex> encode(i64())
"Int64"

iex> decode("Int64")
i64()

Helper for Int128 ClickHouse type:

iex> i128()
:i128

iex> encode(i128())
"Int128"

iex> decode("Int128")
i128()

Helper for Int256 ClickHouse type:

iex> i256()
:i256

iex> encode(i256())
"Int256"

iex> decode("Int256")
i256()

Helper for IPv4 ClickHouse type:

iex> ipv4()
:ipv4

iex> encode(ipv4())
"IPv4"

iex> decode("IPv4")
ipv4()

Helper for IPv6 ClickHouse type:

iex> ipv6()
:ipv6

iex> encode(ipv6())
"IPv6"

iex> decode("IPv6")
ipv6()

Helper for LowCardinality(T) ClickHouse type:

iex> low_cardinality(string())
{:low_cardinality, :string}

iex> to_string(encode(low_cardinality(string())))
"LowCardinality(String)"

iex> decode("LowCardinality(String)")
low_cardinality(string())
Link to this function

map(key_type, value_type)

View Source

Helper for Map(K, V) ClickHouse type:

iex> map(string(), array(string()))
{:map, :string, {:array, :string}}

iex> to_string(encode(map(string(), array(string()))))
"Map(String, Array(String))"

iex> decode("Map(String, Array(String))")
map(string(), array(string()))

Helper for MultiPolygon ClickHouse type:

iex> multipolygon()
:multipolygon

iex> encode(multipolygon())
"MultiPolygon"

iex> decode("MultiPolygon")
multipolygon()

Helper for Nothing ClickHouse type:

iex> nothing()
:nothing

iex> encode(nothing())
"Nothing"

iex> decode("Nothing")
nothing()

Helper for Nullable(T) ClickHouse type:

iex> nullable(array(boolean()))
{:nullable, {:array, :boolean}}

iex> to_string(encode(nullable(array(boolean()))))
"Nullable(Array(Bool))"

iex> decode("Nullable(Array(Bool))")
nullable(array(boolean()))

Helper for Point ClickHouse type:

iex> point()
:point

iex> encode(point())
"Point"

iex> decode("Point")
point()

Helper for Polygon ClickHouse type:

iex> polygon()
:polygon

iex> encode(polygon())
"Polygon"

iex> decode("Polygon")
polygon()

Helper for Ring ClickHouse type:

iex> ring()
:ring

iex> encode(ring())
"Ring"

iex> decode("Ring")
ring()
Link to this function

simple_aggregate_function(name, type)

View Source

Helper for SimpleAggregateFunction(name, type) ClickHouse type:

iex> simple_aggregate_function("any", u8())
{:simple_aggregate_function, "any", :u8}

iex> to_string(encode(simple_aggregate_function("any", u8())))
"SimpleAggregateFunction(any, UInt8)"

iex> decode("SimpleAggregateFunction(any, UInt8)")
simple_aggregate_function("any", u8())

Helper for String ClickHouse type:

iex> string()
:string

iex> encode(string())
"String"

iex> decode("String")
string()

Helper for Tuple(T1, T2, ...) ClickHouse type:

iex> tuple([u64(), array(string())])
{:tuple, [:u64, {:array, :string}]}

iex> to_string(encode(tuple([u64(), array(string())])))
"Tuple(UInt64, Array(String))"

iex> decode("Tuple(UInt64, Array(String))")
tuple([u64(), array(string())])

Helper for UInt8 ClickHouse type:

iex> u8()
:u8

iex> encode(u8())
"UInt8"

iex> decode("UInt8")
u8()

Helper for UInt16 ClickHouse type:

iex> u16()
:u16

iex> encode(u16())
"UInt16"

iex> decode("UInt16")
u16()

Helper for UInt32 ClickHouse type:

iex> u32()
:u32

iex> encode(u32())
"UInt32"

iex> decode("UInt32")
u32()

Helper for UInt64 ClickHouse type:

iex> u64()
:u64

iex> encode(u64())
"UInt64"

iex> decode("UInt64")
u64()

Helper for UInt128 ClickHouse type:

iex> u128()
:u128

iex> encode(u128())
"UInt128"

iex> decode("UInt128")
u128()

Helper for UInt256 ClickHouse type:

iex> u256()
:u256

iex> encode(u256())
"UInt256"

iex> decode("UInt256")
u256()

Helper for UUID ClickHouse type:

iex> uuid()
:uuid

iex> encode(uuid())
"UUID"

iex> decode("UUID")
uuid()