2 Utility methods for parsing data returned from HeavyDB
6 from collections
import namedtuple
7 from sqlalchemy
import text
9 from ._utils
import seconds_to_time, datetime_in_precisions
11 Description = namedtuple(
23 ColumnDetails = namedtuple(
52 'MULTIPOLYGON':
'str',
57 _thrift_types_to_values = T.TDatumType._NAMES_TO_VALUES
58 _thrift_values_to_types = T.TDatumType._VALUES_TO_NAMES
59 _thrift_encodings_to_values = T.TEncodingType._NAMES_TO_VALUES
60 _thrift_values_to_encodings = T.TEncodingType._VALUES_TO_NAMES
75 base = datetime.datetime(1970, 1, 1)
77 None if v
is None else (base + datetime.timedelta(seconds=v)).date()
89 typename = T.TDatumType._VALUES_TO_NAMES[desc.col_type.type]
94 if hasattr(val.data,
'arr_col')
and val.data.arr_col:
96 None if null
else getattr(v.data, _typeattr[typename] +
'_col')
97 for null, v
in zip(nulls, val.data.arr_col)
100 if typename ==
'TIMESTAMP':
102 elif typename ==
'DATE':
104 elif typename ==
'TIME':
109 vals = getattr(val.data, _typeattr[typename] +
'_col')
110 vals = [
None if null
else v
for null, v
in zip(nulls, vals)]
112 if typename ==
'TIMESTAMP':
114 elif typename ==
'DATE':
116 elif typename ==
'TIME':
124 Return a tuple of (name, type_code, display_size, internal_size,
125 precision, scale, null_ok)
127 https://www.python.org/dev/peps/pep-0249/#description
137 col.col_type.nullable,
148 _thrift_values_to_types[x.col_type.type],
150 x.col_type.precision,
152 x.col_type.comp_param,
153 _thrift_values_to_encodings[x.col_type.encoding],
163 .bindparams(**parameters)
164 .compile(compile_kwargs={
"literal_binds":
True})
def _extract_column_details
def datetime_in_precisions
def _format_result_timestamp