Skip to content

Introduce SeaDatabricksClient (Session Implementation) #582

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.

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
merged 25 commits into from
Jun 9, 2025

Conversation

varun-edachali-dbx
Copy link
Collaborator

@varun-edachali-dbx varun-edachali-dbx commented Jun 3, 2025

What type of PR is this?

  • Feature

Description

  • Introduce SEA Backend client as an alternative to the existing Thrift backend
  • implement open_session() and close_session() functionality.

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually - the test script examples/experimental/sea_connector_test.py in the sea-migration branch contains a simple function that creates and closes a connection using the SEA mode, effectively opening and closing a session using the SEA client. This was run, and verified to work.
  • N/A

The coverage of the newly introduced backend/sea directory by the unit tests is as below:

Module Statements Missing Coverage Notes
backend.py 96 1 99% Line 6: from databricks.sql.client import Cursor (TYPE_CHECKING import)
models/__init__.py 3 0 100% Fully covered
models/requests.py 23 0 100% Fully covered
models/responses.py 8 0 100% Fully covered
utils/constants.py 2 0 100% Fully covered
utils/http_client.py 76 63 17% Missing coverage in:
- Lines 44-80: SSL configuration in __init__
- Lines 86-88: _get_auth_headers method
- Lines 92-99: _get_call method
- Lines 124-186: Error handling in _make_request method

Note: I intentionally did not add unit tests for the HTTP client because I do not expect it to change and it is for the short term. It has been indirectly tested as a part of the manual tests.

Related Tickets & Documents

https://docs.google.com/document/d/1Y-eXLhNqqhrMVGnOlG8sdFrCxBTN1GdQvuKG4IfHmo0/edit?usp=sharing
https://databricks.atlassian.net/browse/PECOBLR-482?atlOrigin=eyJpIjoiODdkMGQ5NjZhMjY5NDRmZWEwZmIyNGEyNzFlNGQxNzEiLCJwIjoiaiJ9

@varun-edachali-dbx varun-edachali-dbx marked this pull request as ready for review June 4, 2025 06:28
@varun-edachali-dbx varun-edachali-dbx changed the title Introduce SeaDatabricksClient (Session Implementation) Introduce SeaDatabricksClient (Session Implementation) Jun 4, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
@databricks databricks deleted a comment from github-actions bot Jun 5, 2025
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
@samikshya-db
Copy link
Contributor

Have we tested this end to end locally? If yes, let's add that detail in the PR description

Copy link
Contributor

@jayantsing-db jayantsing-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. Rest LGTM

"""

warehouse_pattern = re.compile(r".*/warehouses/(.+)")
endpoint_pattern = re.compile(r".*/endpoints/(.+)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have endpoints now? i don't think so

Copy link
Collaborator Author

@varun-edachali-dbx varun-edachali-dbx Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JDBC driver supports it.

Opens a new session with the Databricks SQL service using SEA.

Args:
session_configuration: Optional dictionary of configuration parameters for the session
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now only a select spark configs are allowed in DBSQL as session configs: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-parameters

please document this appropriately. also, please test if server ignores any other arbitrary session config. if not, please include client-side checks/filtering

Copy link
Collaborator Author

@varun-edachali-dbx varun-edachali-dbx Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I added a link to the above doc in the doc-string.

I tested passing some arbitrary (un-supported) parameters in the session config and I did not get any warning or error from the server, so the server seems to ignore irrelevant params.

To be clear, this means we need not include any client side filtering, right?

Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
Copy link
Contributor

@samikshya-db samikshya-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

…ver endoints

Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
@varun-edachali-dbx varun-edachali-dbx merged commit 0887bc1 into sea-migration Jun 9, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants