Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion hotdata/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,11 @@ def _follow_arrow(

batches = []
fetched = 0
# Ask for one row past the guard at most: enough to detect the overflow,
# without downloading an oversized result only to discard it.
limit = max_auto_rows + 1 if max_auto_rows is not None else None
with _ArrowResultsApi(self.api_client).stream_result_arrow(
result_id, x_database_id, _request_timeout=_request_timeout
result_id, x_database_id, limit=limit, _request_timeout=_request_timeout
) as reader:
for batch in reader:
fetched += batch.num_rows
Expand Down
2 changes: 2 additions & 0 deletions tests/test_query_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ def test_follow_row_guard_holds_when_run_lookup_fails(calls: Any) -> None:
with pytest.raises(ResultTooLargeError) as ei:
_api().query_arrow(REQ, x_database_id="db1", max_auto_rows=2)
assert ei.value.observed == 3
# The read asks for one row past the guard, not the whole result.
assert "limit=3" in calls[3]["url"]


def test_follow_survives_failed_run_lookup(calls: Any) -> None:
Expand Down