forked from ibis-project/ibis
/
types.py
72 lines (63 loc) · 2.68 KB
/
types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# TODO: support more type
# Array, Tuple, Enum, Nested, AggregateFunction, UUID
# Nullable(UInt8), FixedString(5) etc.
# def type_to_sql_string(ibis_type):
# return ibis_to_clickhouse[ibis_type.name.lower()]
# def sql_string_to_type(sql_type):
# return clickhouse_to_ibis[sql_type.name.lower()]
pandas_to_clickhouse = {'object': 'String',
'uint64': 'UInt64',
'uint32': 'UInt32',
'uint16': 'UInt16',
'float64': 'Float64',
'float32': 'Float32',
'uint8': 'UInt8',
'int64': 'Int64',
'int32': 'Int32',
'int16': 'Int16',
'int8': 'Int8',
'bool': 'UInt8',
'datetime64[D]': 'Date',
'datetime64[ns]': 'DateTime'}
clickhouse_to_pandas = {'UInt8': 'uint8',
'UInt16': 'uint16',
'UInt32': 'uint32',
'UInt64': 'uint64',
'Int8': 'int8',
'Int16': 'int16',
'Int32': 'int32',
'Int64': 'int64',
'Float64': 'float64',
'Float32': 'float32',
'String': 'object',
'FixedString': 'object', # TODO
'Null': 'object',
'Date': 'datetime64[D]',
'DateTime': 'datetime64[ns]'}
ibis_to_clickhouse = {'null': 'Null',
'int8': 'Int8',
'int16': 'Int16',
'int32': 'Int32',
'int64': 'Int64',
'float': 'Float32',
'double': 'Float64',
'string': 'String',
'boolean': 'UInt8',
'date': 'Date',
'timestamp': 'DateTime',
'decimal': 'UInt64'} # see Clickhouse issue #253
clickhouse_to_ibis = {'Null': 'null',
'UInt64': 'int64',
'UInt32': 'int32',
'UInt16': 'int16',
'UInt8': 'int8',
'Int64': 'int64',
'Int32': 'int32',
'Int16': 'int16',
'Int8': 'int8',
'Float64': 'double',
'Float32': 'float',
'String': 'string',
'FixedString': 'string',
'Date': 'date',
'DateTime': 'timestamp'}