Skip to content

Commit e3a8d94

Browse files
fix(kernel): honor the Arrow compression setting
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
1 parent 31b3ba4 commit e3a8d94

3 files changed

Lines changed: 42 additions & 9 deletions

File tree

‎CONNECTION_PARAMETERS.md‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ environment. The backends differ for SOCKS proxies:
171171
| ------------------------------------- | ------ | :----: | :----: | ------------- | ------------------------------------------------------------------------------------------------------------- |
172172
| `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. |
173173
| `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. |
174-
| `enable_query_result_lz4_compression` | `bool` | ✅ | ❌ | `True` | LZ4-compress result payloads. Not forwarded; the kernel handles compression internally. |
174+
| `enable_query_result_lz4_compression` | `bool` | ✅ | ✅ | `True` | Request LZ4 compression for Arrow results. Set `False` to request uncompressed results. |
175175
| `_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. |
176176
| `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. |
177177
| `_use_arrow_native_complex_types` | `bool` | ✅ | ✅ | `True` | Return `ARRAY`/`MAP`/`STRUCT` as native Arrow types instead of JSON strings. Forwarded to the kernel. |
@@ -224,16 +224,14 @@ are forwarded when supported by the installed kernel binding.
224224
2. `experimental_oauth_persistence` (custom OAuth token store).
225225
3. TLS-client-cert *authentication* (`_use_cert_as_auth`) — note the TLS
226226
*transport* options (`_tls_*`) themselves **are** honored on both backends.
227-
4. Result-transport tuning:
228-
`enable_query_result_lz4_compression`.
229-
5. Arrow-native rendering for `_use_arrow_native_decimals` /
227+
4. Arrow-native rendering for `_use_arrow_native_decimals` /
230228
`_use_arrow_native_timestamps` (complex types **are** forwarded).
231-
6. `staging_allowed_local_path` (Volume `PUT`/`GET`).
232-
7. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`,
229+
5. `staging_allowed_local_path` (Volume `PUT`/`GET`).
230+
6. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`,
233231
`_retry_dangerous_codes`, `_respect_server_retry_after_header`,
234232
`_retry_max_redirects`, `_enable_v3_retries`.
235-
8. `force_enable_telemetry`.
236-
9. `_pool_connections` and `_proxy_auth_method` do not configure the
233+
7. `force_enable_telemetry`.
234+
8. `_pool_connections` and `_proxy_auth_method` do not configure the
237235
kernel-owned network stack.
238236

239237
### Supported on Kernel, missing / ignored on Thrift

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ def execute_command(
685685
try:
686686
stmt.set_sql(operation)
687687
stmt.set_row_limit(row_limit)
688+
stmt.set_lz4_compression(lz4_compression)
688689
if query_tags:
689690
# Per-statement query tags. The kernel serialises the
690691
# dict (None value -> bare key) into the SEA

‎tests/unit/test_kernel_client.py‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import types
1919
from concurrent.futures import ThreadPoolExecutor
2020
from typing import Optional
21-
from unittest.mock import MagicMock
21+
from unittest.mock import call, MagicMock
2222

2323
import pytest
2424

@@ -1139,6 +1139,40 @@ def test_execute_command_forwards_row_limit(row_limit):
11391139
stmt.set_row_limit.assert_called_once_with(row_limit)
11401140

11411141

1142+
@pytest.mark.parametrize("async_op", [False, True])
1143+
def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
1144+
client = _make_client()
1145+
client._kernel_session = MagicMock()
1146+
cursor = MagicMock(arraysize=100, buffer_size_bytes=1024)
1147+
statements = [MagicMock(), MagicMock()]
1148+
client._kernel_session.statement.side_effect = statements
1149+
1150+
for stmt, enabled in zip(statements, [True, False]):
1151+
stmt.execute.return_value = MagicMock(
1152+
statement_id="stmt-id",
1153+
arrow_schema=MagicMock(return_value=pa.schema([("x", pa.int64())])),
1154+
)
1155+
stmt.submit.return_value.statement_id = "stmt-id"
1156+
client.execute_command(
1157+
operation="SELECT 1",
1158+
session_id=MagicMock(),
1159+
max_rows=1,
1160+
max_bytes=1,
1161+
lz4_compression=enabled,
1162+
cursor=cursor,
1163+
use_cloud_fetch=True,
1164+
parameters=[],
1165+
async_op=async_op,
1166+
enforce_embedded_schema_correctness=False,
1167+
)
1168+
1169+
dispatch = call.submit() if async_op else call.execute()
1170+
stmt.set_lz4_compression.assert_called_once_with(enabled)
1171+
assert stmt.method_calls.index(call.set_lz4_compression(enabled)) < (
1172+
stmt.method_calls.index(dispatch)
1173+
)
1174+
1175+
11421176
# ---------------------------------------------------------------------------
11431177
# Staging / volume operations — fail loud (not silently no-op)
11441178
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)