diff --git a/trino/client.py b/trino/client.py index e262f626..053e23cb 100644 --- a/trino/client.py +++ b/trino/client.py @@ -688,11 +688,11 @@ def __init__(self, query, rows: List[Any]): self._rownumber = 0 @property - def rows(self): + def rows(self) -> List[Any]: return self._rows @rows.setter - def rows(self, rows): + def rows(self, rows: List[Any]): self._rows = rows @property @@ -702,14 +702,13 @@ def rownumber(self) -> int: def __iter__(self): # A query only transitions to a FINISHED state when the results are fully consumed: # The reception of the data is acknowledged by calling the next_uri before exposing the data through dbapi. - while not self._query.finished or self._rows is not None: - next_rows = self._query.fetch() if not self._query.finished else None + while not self._query.finished or self._rows: for row in self._rows: self._rownumber += 1 logger.debug("row %s", row) yield row - self._rows = next_rows + self._rows = self._query.fetch() if not self._query.finished else [] class TrinoQuery(object):