GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [ES-402013] Close cursors before closing connection by susodapop · Pull Request #38 · databricks/databricks-sql-python

[ES-402013] Close cursors before closing connection #38

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.

Sign up for GitHub

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

Merged
susodapop merged 2 commits into main from ES-402013
Aug 23, 2022

Uh oh!

There was an error while loading. Please reload this page.

Merged

[ES-402013] Close cursors before closing connection #38

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
5ae9486
Add test: cursors are closed when connection closes
susodapop Aug 23, 2022
b80cb71
Close cursors before closing connection
susodapop Aug 23, 2022
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

5 changes: 2 additions & 3 deletions 5 src/databricks/sql/client.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,11 @@ def close(self) -> None:
self._close()

def _close(self, close_cursors=True) -> None:
self.thrift_backend.close_session(self._session_handle)
self.open = False

if close_cursors:
for cursor in self._cursors:
cursor.close()
self.thrift_backend.close_session(self._session_handle)
self.open = False

def commit(self):
"""No-op because Databricks does not support transactions"""
Expand Down
26 changes: 26 additions & 0 deletions 26 tests/e2e/driver_tests.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,32 @@ def test_decimal_not_returned_as_strings_arrow(self):
decimal_type = arrow_df.field(0).type
self.assertTrue(pyarrow.types.is_decimal(decimal_type))

def test_close_connection_closes_cursors(self):

from databricks.sql.thrift_api.TCLIService import ttypes

with self.connection() as conn:
cursor = conn.cursor()
cursor.execute('SELECT id, id `id2`, id `id3` FROM RANGE(1000000) order by RANDOM()')
ars = cursor.active_result_set

# We must manually run this check because thrift_backend always forces `has_been_closed_server_side` to True

# Cursor op state should be open before connection is closed
status_request = ttypes.TGetOperationStatusReq(operationHandle=ars.command_id, getProgressUpdate=False)
op_status_at_server = ars.thrift_backend._client.GetOperationStatus(status_request)
assert op_status_at_server.operationState != ttypes.TOperationState.CLOSED_STATE

conn.close()

# When connection closes, any cursor operations should no longer exist at the server
with self.assertRaises(thrift.Thrift.TApplicationException) as cm:
op_status_at_server = ars.thrift_backend._client.GetOperationStatus(status_request)
if hasattr(cm, "exception"):
assert "RESOURCE_DOES_NOT_EXIST" in cm.exception.message




# use a RetrySuite to encapsulate these tests which we'll typically want to run together; however keep
# the 429/503 subsuites separate since they execute under different circumstances.
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.