Skip to content

Commit 4de4f55

Browse files
committed
SNOW-1759076: async for support in cursor get result batches (#2080)
1 parent 957c85c commit 4de4f55

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/snowflake/connector/aio/_result_batch.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import asyncio
99
import json
1010
from logging import getLogger
11-
from typing import TYPE_CHECKING, Any, AsyncIterator, Iterator, Sequence
11+
from typing import TYPE_CHECKING, Any, Iterator, Sequence
1212

1313
import aiohttp
1414

@@ -168,16 +168,21 @@ def remote_chunk_info(c: dict[str, Any]) -> RemoteChunkInfo:
168168

169169

170170
class ResultBatch(ResultBatchSync):
171-
pass
171+
def __iter__(self):
172+
raise TypeError(
173+
f"Async '{type(self).__name__}' does not support '__iter__', "
174+
f"please call the `create_iter` coroutine method on the '{type(self).__name__}' object"
175+
" to explicitly create an iterator."
176+
)
172177

173178
@abc.abstractmethod
174179
async def create_iter(
175180
self, **kwargs
176181
) -> (
177-
AsyncIterator[dict | Exception]
178-
| AsyncIterator[tuple | Exception]
179-
| AsyncIterator[Table]
180-
| AsyncIterator[DataFrame]
182+
Iterator[dict | Exception]
183+
| Iterator[tuple | Exception]
184+
| Iterator[Table]
185+
| Iterator[DataFrame]
181186
):
182187
"""Downloads the data from blob storage that this ResultChunk points at.
183188

0 commit comments

Comments
 (0)