Type mappings

November 29, 2021 ยท View on GitHub

ClickHouse type. The type of the column.

Default type. This is the type returned by Octonica.ClickHouseClient.ClickHouseDataReader.GetFieldType(int ordinal). The method Octonica.ClickHouseClient.ClickHouseDataReader.GetValue(int ordinal) returns either a value of the default type or System.DBNull.

Supported types. The value can be converted to one of this types.

ClickHouseDataReader's method. The method dedicated to the default type.

You can get the value of one of supported types by calling GetFieldValue<T>(int ordinal) or GetFieldValue<T>(int ordinal, T? nullValue). The latter doesn't throw an error on NULL value.

ClickHouse typeDefault typeSupported typesClickHouseDataReader's method
Int8sbyteshort, int, longGetSByte
Int16shortint, longGetInt16
Int32intlongGetInt32
Int64longGetInt64
Int128System.Numerics.BigIntegerGetBigInteger
Int256System.Numerics.BigIntegerGetBigInteger
UInt8byteushort, uint, ulong, int, longGetByte
UInt16ushortuint, ulong, int, longGetUInt16
UInt32uintulong, longGetUInt132
UInt64ulongGetUInt64
UInt128System.Numerics.BigIntegerGetBigInteger
UInt256System.Numerics.BigIntegerGetBigInteger
Float32floatdoubleGetFloat
Float64doubleGetDouble
DecimaldecimalGetDecimal
Date*System.DateOnlySystem.DateTimeGetDate
Date32*System.DateOnlySystem.DateTimeGetDate
DateTimeSystem.DateTimeOffsetSystem.DateTimeGetDateTimeOffset
DateTime64System.DateTimeOffsetSystem.DateTimeGetDateTimeOffset
Stringstringchar[], byte[]GetString
FixedStringbyte[]string, char[]
UUIDSystem.GuidGetGuid
IPv4System.Net.IPAddressstring, int, uintGetIPAddress
IPv6System.Net.IPAddressstringGetIPAddress
Enum8stringsbyte, short, int, long
Enum16stringshort, int, long
NothingSystem.DBNullGetValue
Nullable(T)T?
Array(T)T[]
Tuple(T1, ... Tn)System.Tuple<T1, ... Tn>System.ValueTuple<T1, ... Tn>
LowCardinalityTThe method for T
Map(TKey, TValue)System.Collections.Generic.KeyValuePair<TKey, TValue>[]System.Tuple<TKey, TValue>[], System.ValueTuple<TKey, TValue>[]

* The type System.DateOnly is available since .NET 6.0. For previous .NET versions dates are mapped to System.DateTime.