-
Notifications
You must be signed in to change notification settings - Fork 194
Return a single element while iterating over segments #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1187,7 +1187,8 @@ def __iter__(self) -> Iterator[Tuple["SpooledData", "Segment"]]: | |
return self | ||
|
||
def __next__(self) -> Tuple["SpooledData", "Segment"]: | ||
return self, next(self._segments_iterator) | ||
segment = next(self._segments_iterator) | ||
return SpooledData(self._encoding, [segment]), segment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not also change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, each response can contain multiple segment URLs, so we need the transfer object to reflect that, but the abstraction we expose to the client doesn't need to mirror that. |
||
|
||
def __repr__(self): | ||
return (f"SpooledData(encoding={self._encoding}, segments={list(self._segments)})") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -742,7 +742,7 @@ def execute(self, operation, params=None): | |
self._query = trino.client.TrinoQuery(self._request, query=operation, | ||
legacy_primitive_types=self._legacy_primitive_types, | ||
fetch_mode="segments") | ||
self._iterator = iter(self._query.execute()) | ||
self._iterator = map(lambda tuple: tuple[0], iter(self._query.execute())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note this is a breaking change, but i agree it is a nicer API. However, how can the client retrieve the encoding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the usage in the integration test |
||
return self | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change import to
from trino.mapper import RowMapperFactory