clickhouse-data-type 0.2.0

ClickHouse Data Types
Documentation
type_name = {
    UInt256 | UInt64 | UInt32 | UInt16 | UInt8 |
    Int256 | Int128 | Int64 | Int32 | Int16 | Int8 |
    Float32 | Float64 |
    Decimal |
    String |
    FixedString |
    UUID |
    DateTime64 | DateTime | Date |
    Enum16 | Enum8 |
    IPv4 | IPv6 |
    // 
    // 
    //
    LowCardinality |
    Nullable |
    Point | Ring | Polygon | MultiPolygon |
    // 
    // 
    // 
    Array |
    Tuple |
    Map
}


UInt8 = { "UInt8" }
UInt16 = { "UInt16" }
UInt32 = { "UInt32" }
UInt64 = { "UInt64" }
UInt256 = { "UInt256" }
Int8 = { "Int8" }
Int16 = { "Int16" }
Int32 = { "Int32" }
Int64 = { "Int64" }
Int128 = { "Int128" }
Int256 = { "Int256" }

Float32 = { "Float32" }
Float64 = { "Float64" }

Decimal = { "Decimal" ~ "(" ~ Decimal_precision ~ "," ~ Decimal_scale ~ ")" }
Decimal_precision = @{ ASCII_NONZERO_DIGIT{1, 2} }
Decimal_scale = @{ ASCII_DIGIT{1, 2} }

String = { "String" }

FixedString = { "FixedString" ~ "(" ~ FixedString_n ~ ")" }
FixedString_n = @{ ASCII_NONZERO_DIGIT+ }

UUID = { "UUID" }

Date = { "Date" }
DateTime = { "DateTime" ~ "(" ~ "'" ~ DateTime_timezone ~ "'" ~ ")" | "DateTime" }
DateTime64 = { "DateTime64" ~ "(" ~ DateTime64_precision ~ ("," ~ "'" ~ DateTime_timezone ~ "'" )? ~ ")" }
DateTime64_precision = @{ ASCII_DIGIT }
DateTime_timezone = @{ DateTime_timezone_char+ ~ "/" ~ DateTime_timezone_char+ | DateTime_timezone_char+ }
DateTime_timezone_char = @{ ASCII_ALPHA | "-" | "_" }

Enum8 = { "Enum8" ~ "(" ~ Enum_pair ~ ("," ~ Enum_pair)* ~ ")" }
Enum16 = { "Enum16" ~ "(" ~ Enum_pair ~ ("," ~ Enum_pair)* ~ ")" }
Enum_pair = { "'" ~ Enum_key ~ "'" ~ " "* ~ "=" ~ " "* ~ Enum_value }
Enum_key = @{ ASCII_ALPHANUMERIC+ }
Enum_value = @{ "-"? ~ ASCII_DIGIT+ }

IPv4 = { "IPv4" }

IPv6 = { "IPv6" }

LowCardinality = { "LowCardinality" ~ "(" ~ LowCardinality_data_type ~ ")" }
LowCardinality_data_type = {
    UInt64 | UInt32 | UInt16 | UInt8 |
    Int64 | Int32 | Int16 | Int8 |
    Float32 | Float64 |
    String |
    FixedString |
    DateTime | Date |
    Enum16 | Enum8 |
    IPv4 | IPv6 |
    // 
    // 
    // 
    Nullable
}

Nullable = { "Nullable" ~ "(" ~ Nullable_type_name ~ ")" }
Nullable_type_name = {
    Nullable_Nothing |
    UInt256 | UInt64 | UInt32 | UInt16 | UInt8 |
    Int256 | Int128 | Int64 | Int32 | Int16 | Int8 |
    Float32 | Float64 |
    Decimal |
    String |
    FixedString |
    UUID |
    DateTime64 | DateTime | Date |
    Enum16 | Enum8 |
    IPv4 | IPv6
}
Nullable_Nothing = { "Nothing" }

Array = { "Array" ~ "(" ~ type_name ~ ")" }

Tuple = { "Tuple" ~ "(" ~ type_name ~ ("," ~ type_name)* ~ ")" }

Map = { "Map" ~ "(" ~ Map_key ~ "," ~ Map_value ~ ")" }
Map_key = {
    UInt256 | UInt64 | UInt32 | UInt16 | UInt8 |
    Int256 | Int128 | Int64 | Int32 | Int16 | Int8 |
    Float32 | Float64 |
    Decimal |
    String |
    FixedString
}
Map_value = {
    UInt256 | UInt64 | UInt32 | UInt16 | UInt8 |
    Int256 | Int128 | Int64 | Int32 | Int16 | Int8 |
    Float32 | Float64 |
    Decimal |
    String |
    FixedString |
    // 
    // 
    // 
    Array
}

// geo
Point = { "Point" }
Ring = { "Ring" }
Polygon = { "Polygon" }
MultiPolygon = { "MultiPolygon" }

WHITESPACE = _{ " " }