in python-phoenixdb/phoenixdb/cursor.py [0:0]
def _transform_row(self, row):
"""Transforms a Row into Python values.
:param row:
A ``common_pb2.Row`` object.
:returns:
A list of values casted into the correct Python types.
:raises:
NotImplementedError
"""
tmp_row = []
for i, column in enumerate(row.value):
if column.scalar_value.null:
tmp_row.append(None)
elif column.has_array_value:
field_name, rep, mutate_to, cast_from = self._column_data_types[i]
list_value = []
for j, typed_value in enumerate(column.array_value):
value = getattr(typed_value, field_name)
if cast_from is not None:
value = cast_from(value)
list_value.append(value)
tmp_row.append(list_value)
else:
field_name, rep, mutate_to, cast_from = self._column_data_types[i]
# get the value from the field_name
value = getattr(column.scalar_value, field_name)
# cast the value
if cast_from is not None:
value = cast_from(value)
tmp_row.append(value)
return tmp_row