Skip to content

Commit 01c3381

Browse files
mdesmetebyhr
authored andcommitted
Fix experimental_python_types on first POST request
1 parent 35ba194 commit 01c3381

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

trino/client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def __iter__(self):
504504
# Initial fetch from the first POST request
505505
for row in self._rows:
506506
self._rownumber += 1
507-
yield row
507+
yield self._map_row(self._experimental_python_types, row, self._query.columns)
508508
self._rows = None
509509

510510
# Subsequent fetches from GET requests until next_uri is empty.
@@ -513,15 +513,19 @@ def __iter__(self):
513513
for row in rows:
514514
self._rownumber += 1
515515
logger.debug("row %s", row)
516-
if not self._experimental_python_types:
517-
yield row
518-
else:
519-
yield self._map_to_python_types(row, self._query.columns)
516+
yield self._map_row(self._experimental_python_types, row, self._query.columns)
520517

521518
@property
522519
def response_headers(self):
523520
return self._query.response_headers
524521

522+
@classmethod
523+
def _map_row(cls, experimental_python_types, row, columns):
524+
if not experimental_python_types:
525+
return row
526+
else:
527+
return cls._map_to_python_types(cls, row, columns)
528+
525529
@classmethod
526530
def _map_to_python_type(cls, item: Tuple[Any, Dict]) -> Any:
527531
(value, data_type) = item

0 commit comments

Comments
 (0)