Skip to content

Commit d517411

Browse files
fix(kernel): check support for HTTP/2 options
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
1 parent 5f7db3e commit d517411

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

‎CONNECTION_PARAMETERS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ to change without notice.
114114
115115
| Option | Type | Thrift | Kernel | Default Value | Note |
116116
| ------------------------------------ | ----------- | :----: | :----: | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
117+
| `enable_http2` | `bool` | ❌ | ✅ | `None` (kernel default `True`) | Negotiate HTTP/2 for HTTPS with HTTP/1.1 fallback. `False` or configured proxies force HTTP/1.1. An explicit value requires a supporting kernel wheel; otherwise raises `NotSupportedError`. |
117118
| `_socket_timeout` | `float` (s) | ✅ | ✅ | `900` (Thrift); `120` (kernel) | Thrift: socket send/recv/connect timeout. Kernel: total HTTP request deadline from connect through response-body completion. A positive value is forwarded; unset or `0` selects the kernel's 120s default. On the kernel path, `0` is neither unlimited nor an immediate timeout. |
118119
| `_pool_connections` | `int` | ⚠️ | ❌ | `10` | Number of pools in the shared Python HTTP client. On Thrift this affects auxiliary auth/feature-flag/telemetry traffic, not the separate Thrift query transport. Kernel-owned network traffic does not use this client. |
119120
| `_pool_maxsize` | `int` | ⚠️ | ⚠️ | `20` (Python); `100` (kernel when unset) | Max idle connections retained per host. It configures the shared Python client but not the Thrift query transport. With kernel ≥ 1.1.0, a positive value also configures the kernel's Rust HTTP pool. Unset or `0` keeps each client's default. |

‎README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ connection = sql.connect(
5454
Notes:
5555
- HTTPS uses HTTP/2 with HTTP/1.1 fallback. `enable_http2=False` or configured
5656
proxy environment variables force HTTP/1.1 for session requests, including
57-
bypassed destinations. Telemetry may reuse an earlier session's HTTP client
58-
for the same host.
57+
bypassed destinations.
5958
- Requires **Python >= 3.10** (the kernel wheel is published as
6059
`cp310-abi3`). On older interpreters the `[kernel]` extra installs
6160
nothing and `use_kernel=True` raises an `ImportError`.

‎src/databricks/sql/backend/kernel/client.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ def _kernel_http2_kwargs(value: Optional[bool]) -> Dict[str, bool]:
223223
return {}
224224
if not isinstance(value, bool):
225225
raise ValueError("enable_http2 must be a bool")
226+
if not _kernel_session_accepts_kwarg("enable_http2"):
227+
raise NotSupportedError(
228+
"enable_http2 requires a newer databricks-sql-kernel wheel "
229+
"that supports HTTP/2 configuration."
230+
)
226231
return {"enable_http2": value}
227232

228233

‎src/databricks/sql/client.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def __init__(
197197
Kernel backend only. Negotiate HTTP/2 for session HTTPS
198198
traffic, with HTTP/1.1 fallback. ``False`` or configured proxy
199199
environment variables force HTTP/1.1, including bypassed hosts.
200-
Telemetry may reuse an earlier session's HTTP client for the same host.
201200
:param enable_geospatial_support: `bool`, optional (default is False)
202201
Kernel backend only. Controls the public representation of
203202
``GEOMETRY`` and ``GEOGRAPHY`` result values. ``True`` returns

‎tests/unit/test_kernel_client.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,21 @@ def test_http2_option_rejects_non_boolean():
437437
kernel_client._kernel_http2_kwargs("false")
438438

439439

440+
def test_http2_option_requires_kernel_support(monkeypatch):
441+
def old_session():
442+
pytest.fail("unsupported HTTP/2 option reached Session")
443+
444+
monkeypatch.setattr(kernel_client._kernel, "Session", old_session)
445+
with pytest.raises(NotSupportedError, match="enable_http2 requires a newer"):
446+
kernel_client.KernelDatabricksClient(
447+
server_hostname="example.cloud.databricks.com",
448+
http_path="/sql/1.0/warehouses/abc",
449+
auth_provider=AccessTokenAuthProvider("dapi-test"),
450+
ssl_options=None,
451+
enable_http2=False,
452+
)
453+
454+
440455
@pytest.mark.parametrize("timeout", [None, 0, 12.5])
441456
def test_open_session_passes_request_timeout_to_kernel(monkeypatch, timeout):
442457
captured = {}

0 commit comments

Comments
 (0)