Skip to content

Commit ae26fc5

Browse files
add close() for Queue, add ResultSet invocation
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent 90f0ac1 commit ae26fc5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/databricks/sql/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ def close(self) -> None:
15051505
and self.connection.open
15061506
):
15071507
self.thrift_backend.close_command(self.command_id)
1508+
self.results.close()
15081509
except RequestError as e:
15091510
if isinstance(e.args[1], CursorAlreadyClosedError):
15101511
logger.info("Operation was canceled by a prior request")

src/databricks/sql/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def next_n_rows(self, num_rows: int):
4646
def remaining_rows(self):
4747
pass
4848

49+
@abstractmethod
50+
def close(self):
51+
pass
52+
4953

5054
class ResultSetQueueFactory(ABC):
5155
@staticmethod
@@ -157,6 +161,9 @@ def remaining_rows(self):
157161
self.cur_row_index += slice.num_rows
158162
return slice
159163

164+
def close(self):
165+
return
166+
160167

161168
class ArrowQueue(ResultSetQueue):
162169
def __init__(
@@ -192,6 +199,9 @@ def remaining_rows(self) -> "pyarrow.Table":
192199
self.cur_row_index += slice.num_rows
193200
return slice
194201

202+
def close(self):
203+
return
204+
195205

196206
class CloudFetchQueue(ResultSetQueue):
197207
def __init__(
@@ -341,6 +351,9 @@ def _create_empty_table(self) -> "pyarrow.Table":
341351
# Create a 0-row table with just the schema bytes
342352
return create_arrow_table_from_arrow_file(self.schema_bytes, self.description)
343353

354+
def close(self):
355+
self.download_manager._shutdown_manager()
356+
344357

345358
ExecuteResponse = namedtuple(
346359
"ExecuteResponse",

0 commit comments

Comments
 (0)