File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -181,13 +181,14 @@ def close(self) -> None:
181
181
self ._close ()
182
182
183
183
def _close (self , close_cursors = True ) -> None :
184
- self .thrift_backend .close_session (self ._session_handle )
185
- self .open = False
186
-
187
184
if close_cursors :
188
185
for cursor in self ._cursors :
189
186
cursor .close ()
190
187
188
+ self .thrift_backend .close_session (self ._session_handle )
189
+ self .open = False
190
+
191
+
191
192
def commit (self ):
192
193
"""No-op because Databricks does not support transactions"""
193
194
pass
Original file line number Diff line number Diff line change @@ -544,6 +544,17 @@ def test_decimal_not_returned_as_strings_arrow(self):
544
544
decimal_type = arrow_df .field (0 ).type
545
545
self .assertTrue (pyarrow .types .is_decimal (decimal_type ))
546
546
547
+ def test_close_connection_closes_cursors (self ):
548
+ with self .connection () as conn :
549
+ cursor = conn .cursor ()
550
+ cursor .execute ('SELECT id, id `id2`, id `id3` FROM RANGE(1000000) order by RANDOM()' )
551
+ ars = cursor .active_result_set
552
+ assert not bool (ars .has_been_closed_server_side )
553
+ conn .close ()
554
+ assert bool (ars .has_been_closed_server_side )
555
+ cursor .close ()
556
+
557
+
547
558
548
559
# use a RetrySuite to encapsulate these tests which we'll typically want to run together; however keep
549
560
# the 429/503 subsuites separate since they execute under different circumstances.
You can’t perform that action at this time.
0 commit comments