View Source Ch.Types (Ch v0.2.5)

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



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


Helper for Array(T) ClickHouse type:

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

iex> to_string(encode(array(u64())))

iex> decode("Array(UInt64)")

Helper for Bool ClickHouse type:

iex> boolean()

iex> encode(boolean())

iex> decode("Bool")

Helper for Date32 ClickHouse type:

iex> date32()

iex> encode(date32())

iex> decode("Date32")

Helper for Date ClickHouse type:

iex> date()

iex> encode(date())

iex> decode("Date")

Helper for DateTime64(precision) ClickHouse type:

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

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

iex> decode("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()

iex> to_string(encode(datetime()))

iex> decode("DateTime")

Helper for DateTime(timezone) ClickHouse type:

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

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

iex> decode("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")

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)

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

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()

iex> encode(f32())

iex> decode("Float32")

Helper for Float64 ClickHouse type:

iex> f64()

iex> encode(f64())

iex> decode("Float64")

Helper for FixedString(n) ClickHouse type:

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

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

iex> decode("FixedString(16)")

Helper for Int8 ClickHouse type:

iex> i8()

iex> encode(i8())

iex> decode("Int8")

Helper for Int16 ClickHouse type:

iex> i16()

iex> encode(i16())

iex> decode("Int16")

Helper for Int32 ClickHouse type:

iex> i32()

iex> encode(i32())

iex> decode("Int32")

Helper for Int64 ClickHouse type:

iex> i64()

iex> encode(i64())

iex> decode("Int64")

Helper for Int128 ClickHouse type:

iex> i128()

iex> encode(i128())

iex> decode("Int128")

Helper for Int256 ClickHouse type:

iex> i256()

iex> encode(i256())

iex> decode("Int256")

Helper for IPv4 ClickHouse type:

iex> ipv4()

iex> encode(ipv4())

iex> decode("IPv4")

Helper for IPv6 ClickHouse type:

iex> ipv6()

iex> encode(ipv6())

iex> decode("IPv6")

Helper for LowCardinality(T) ClickHouse type:

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

iex> to_string(encode(low_cardinality(string())))

iex> decode("LowCardinality(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()

iex> encode(multipolygon())

iex> decode("MultiPolygon")

Helper for Nothing ClickHouse type:

iex> nothing()

iex> encode(nothing())

iex> decode("Nothing")

Helper for Nullable(T) ClickHouse type:

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

iex> to_string(encode(nullable(array(boolean()))))

iex> decode("Nullable(Array(Bool))")

Helper for Point ClickHouse type:

iex> point()

iex> encode(point())

iex> decode("Point")

Helper for Polygon ClickHouse type:

iex> polygon()

iex> encode(polygon())

iex> decode("Polygon")

Helper for Ring ClickHouse type:

iex> ring()

iex> encode(ring())

iex> decode("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()

iex> encode(string())

iex> decode("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()

iex> encode(u8())

iex> decode("UInt8")

Helper for UInt16 ClickHouse type:

iex> u16()

iex> encode(u16())

iex> decode("UInt16")

Helper for UInt32 ClickHouse type:

iex> u32()

iex> encode(u32())

iex> decode("UInt32")

Helper for UInt64 ClickHouse type:

iex> u64()

iex> encode(u64())

iex> decode("UInt64")

Helper for UInt128 ClickHouse type:

iex> u128()

iex> encode(u128())

iex> decode("UInt128")

Helper for UInt256 ClickHouse type:

iex> u256()

iex> encode(u256())

iex> decode("UInt256")

Helper for UUID ClickHouse type:

iex> uuid()

iex> encode(uuid())

iex> decode("UUID")