diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index f0b3d2ee7..58a8556e9 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -151,7 +151,7 @@ to change without notice. | ------------------------------------- | ------ | :----: | :----: | ------------- | ------------------------------------------------------------------------------------------------------------- | | `use_cloud_fetch` | `bool` | ✅ | ✅ | `True` | Set `False` at connection creation to fetch complete results without cloud-storage downloads. On the kernel path, changing this attribute after connecting does not change result delivery. | | `max_download_threads` | `int` | ✅ | ✅ | `16` kernel, `10` Thrift | CloudFetch download window; on the kernel, counts downloading and queued chunks ahead of consumption, excluding consumer buffers. Not a byte limit. | -| `enable_query_result_lz4_compression` | `bool` | ✅ | ❌ | `True` | LZ4-compress result payloads. Not forwarded; the kernel handles compression internally. | +| `enable_query_result_lz4_compression` | `bool` | ✅ | ✅ | `True` | Request LZ4 compression for Arrow results. Set `False` to request uncompressed results. | | `_disable_pandas` | `bool` | ✅ | ✅ | `False` | Skip the pandas-based Arrow→row deserialization and materialize rows directly with PyArrow. This is a **Python-side** result-conversion toggle, not a wire option: the kernel returns results as Arrow (`RecordBatch`es) and the connector runs the *same* `_convert_arrow_table` for both backends, so the flag is honored on the kernel path too. Affects only row fetches (`fetchone`/`fetchmany`/`fetchall`); the `fetch*_arrow` methods return the Arrow table unchanged regardless of this flag. | | `enable_geospatial_support` | `bool` | ❌ | ✅ | `False` | Return GEOMETRY / GEOGRAPHY as `{"srid": int, "wkb": bytes}` values when `True`, or as WKT / EWKT strings when `False`. This is a local result conversion and is never forwarded to SEA. | | `_use_arrow_native_complex_types` | `bool` | ✅ | ✅ | `True` | Return `ARRAY`/`MAP`/`STRUCT` as native Arrow types instead of JSON strings. Forwarded to the kernel. | @@ -204,18 +204,16 @@ are forwarded when supported by the installed kernel binding. 2. `experimental_oauth_persistence` (custom OAuth token store). 3. TLS-client-cert *authentication* (`_use_cert_as_auth`) — note the TLS *transport* options (`_tls_*`) themselves **are** honored on both backends. -4. Result-transport tuning: - `enable_query_result_lz4_compression`. -5. Arrow-native rendering for `_use_arrow_native_decimals` / +4. Arrow-native rendering for `_use_arrow_native_decimals` / `_use_arrow_native_timestamps` (complex types **are** forwarded). -6. `staging_allowed_local_path` (Volume `PUT`/`GET`). -7. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`, +5. `staging_allowed_local_path` (Volume `PUT`/`GET`). +6. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`, `_retry_dangerous_codes`, `_respect_server_retry_after_header`, `_retry_max_redirects`, `_enable_v3_retries`. -8. `force_enable_telemetry`. -9. `_port` and `_connection_uri`. -10. `_pool_connections` and `_proxy_auth_method` do not configure the - kernel-owned network stack. +7. `force_enable_telemetry`. +8. `_port` and `_connection_uri`. +9. `_pool_connections` and `_proxy_auth_method` do not configure the + kernel-owned network stack. ### Supported on Kernel, missing / ignored on Thrift diff --git a/KERNEL_REV b/KERNEL_REV index 2add322e2..98ae92d23 100644 --- a/KERNEL_REV +++ b/KERNEL_REV @@ -1 +1 @@ -5c3a909771f749174567af074bfe18c24a335f5c +4691f70cda81ad2b22c419d876d7aebbdbf878fe diff --git a/src/databricks/sql/backend/kernel/client.py b/src/databricks/sql/backend/kernel/client.py index eab9847ca..ed7e128d8 100644 --- a/src/databricks/sql/backend/kernel/client.py +++ b/src/databricks/sql/backend/kernel/client.py @@ -666,6 +666,7 @@ def execute_command( try: stmt.set_sql(operation) stmt.set_row_limit(row_limit) + stmt.set_lz4_compression(bool(lz4_compression)) if query_tags: # Per-statement query tags. The kernel serialises the # dict (None value -> bare key) into the SEA diff --git a/tests/unit/test_kernel_client.py b/tests/unit/test_kernel_client.py index 5bad2040b..d6ae23c24 100644 --- a/tests/unit/test_kernel_client.py +++ b/tests/unit/test_kernel_client.py @@ -18,7 +18,7 @@ import types from concurrent.futures import ThreadPoolExecutor from typing import Optional -from unittest.mock import MagicMock +from unittest.mock import call, MagicMock import pytest @@ -1009,6 +1009,42 @@ def test_execute_command_forwards_row_limit(row_limit): stmt.set_row_limit.assert_called_once_with(row_limit) +@pytest.mark.parametrize("async_op", [False, True]) +def test_execute_command_forwards_lz4_compression_before_dispatch(async_op): + client = _make_client() + client._kernel_session = MagicMock() + cursor = MagicMock(arraysize=100, buffer_size_bytes=1024) + cases = [(True, True), (False, False), (0, False)] + statements = [MagicMock() for _ in cases] + client._kernel_session.statement.side_effect = statements + + for stmt, (value, expected) in zip(statements, cases): + stmt.execute.return_value = MagicMock( + statement_id="stmt-id", + arrow_schema=MagicMock(return_value=pa.schema([("x", pa.int64())])), + ) + stmt.submit.return_value.statement_id = "stmt-id" + client.execute_command( + operation="SELECT 1", + session_id=MagicMock(), + max_rows=1, + max_bytes=1, + lz4_compression=value, + cursor=cursor, + use_cloud_fetch=True, + parameters=[], + async_op=async_op, + enforce_embedded_schema_correctness=False, + ) + + dispatch = call.submit() if async_op else call.execute() + stmt.set_lz4_compression.assert_called_once_with(expected) + assert stmt.set_lz4_compression.call_args.args[0] is expected + assert stmt.method_calls.index(call.set_lz4_compression(expected)) < ( + stmt.method_calls.index(dispatch) + ) + + # --------------------------------------------------------------------------- # Staging / volume operations — fail loud (not silently no-op) # ---------------------------------------------------------------------------