Skip to content

Commit

Permalink
TrinoResult.rows should not be None
Browse files Browse the repository at this point in the history
  • Loading branch information
dungdm93 committed Aug 8, 2023
1 parent 6eaef4b commit cbc0e12
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions trino/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,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
Expand All @@ -700,14 +700,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):
Expand Down

0 comments on commit cbc0e12

Please sign in to comment.