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 'MULTILINESTRING':
'str',
54 'MULTIPOLYGON':
'str',
59 _thrift_types_to_values = T.TDatumType._NAMES_TO_VALUES
60 _thrift_values_to_types = T.TDatumType._VALUES_TO_NAMES
61 _thrift_encodings_to_values = T.TEncodingType._NAMES_TO_VALUES
62 _thrift_values_to_encodings = T.TEncodingType._VALUES_TO_NAMES
77 base = datetime.datetime(1970, 1, 1)
79 None if v
is None else (base + datetime.timedelta(seconds=v)).date()
91 typename = T.TDatumType._VALUES_TO_NAMES[desc.col_type.type]
96 if hasattr(val.data,
'arr_col')
and val.data.arr_col:
98 None if null
else getattr(v.data, _typeattr[typename] +
'_col')
99 for null, v
in zip(nulls, val.data.arr_col)
102 if typename ==
'TIMESTAMP':
104 elif typename ==
'DATE':
106 elif typename ==
'TIME':
111 vals = getattr(val.data, _typeattr[typename] +
'_col')
112 vals = [
None if null
else v
for null, v
in zip(nulls, vals)]
114 if typename ==
'TIMESTAMP':
116 elif typename ==
'DATE':
118 elif typename ==
'TIME':
126 Return a tuple of (name, type_code, display_size, internal_size,
127 precision, scale, null_ok)
129 https://www.python.org/dev/peps/pep-0249/#description
139 col.col_type.nullable,
150 _thrift_values_to_types[x.col_type.type],
152 x.col_type.precision,
154 x.col_type.comp_param,
155 _thrift_values_to_encodings[x.col_type.encoding],
165 .bindparams(**parameters)
166 .compile(compile_kwargs={
"literal_binds":
True})
def _extract_column_details
def datetime_in_precisions
def _format_result_timestamp