Skip to content

Commit 7818926

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

4 files changed

Lines changed: 43 additions & 10 deletions

File tree

‎CONNECTION_PARAMETERS.md‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ to change without notice.
151151
| ------------------------------------- | ------ | :----: | :----: | ------------- | ------------------------------------------------------------------------------------------------------------- |
152152
| `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. |
153153
| `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. |
154-
| `enable_query_result_lz4_compression` | `bool` | ✅ | ❌ | `True` | LZ4-compress result payloads. Not forwarded; the kernel handles compression internally. |
154+
| `enable_query_result_lz4_compression` | `bool` | ✅ | ✅ | `True` | Request LZ4 compression for Arrow results. Set `False` to request uncompressed results. |
155155
| `_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. |
156156
| `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. |
157157
| `_use_arrow_native_complex_types` | `bool` | ✅ | ✅ | `True` | Return `ARRAY`/`MAP`/`STRUCT` as native Arrow types instead of JSON strings. Forwarded to the kernel. |
@@ -204,16 +204,14 @@ are forwarded when supported by the installed kernel binding.
204204
2. `experimental_oauth_persistence` (custom OAuth token store).
205205
3. TLS-client-cert *authentication* (`_use_cert_as_auth`) — note the TLS
206206
*transport* options (`_tls_*`) themselves **are** honored on both backends.
207-
4. Result-transport tuning:
208-
`enable_query_result_lz4_compression`.
209-
5. Arrow-native rendering for `_use_arrow_native_decimals` /
207+
4. Arrow-native rendering for `_use_arrow_native_decimals` /
210208
`_use_arrow_native_timestamps` (complex types **are** forwarded).
211-
6. `staging_allowed_local_path` (Volume `PUT`/`GET`).
212-
7. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`,
209+
5. `staging_allowed_local_path` (Volume `PUT`/`GET`).
210+
6. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`,
213211
`_retry_dangerous_codes`, `_respect_server_retry_after_header`,
214212
`_retry_max_redirects`, `_enable_v3_retries`.
215-
8. `force_enable_telemetry`.
216-
9. `_pool_connections` and `_proxy_auth_method` do not configure the
213+
7. `force_enable_telemetry`.
214+
8. `_pool_connections` and `_proxy_auth_method` do not configure the
217215
kernel-owned network stack.
218216

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

‎KERNEL_REV‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3b691d2a2c235ef847d61b308c31604979830994
1+
0af849aebfbab6ce06ac2e299d40e7c97a064174

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ def execute_command(
678678
try:
679679
stmt.set_sql(operation)
680680
stmt.set_row_limit(row_limit)
681+
stmt.set_lz4_compression(lz4_compression)
681682
if query_tags:
682683
# Per-statement query tags. The kernel serialises the
683684
# 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

@@ -1073,6 +1073,40 @@ def test_execute_command_forwards_row_limit(row_limit):
10731073
stmt.set_row_limit.assert_called_once_with(row_limit)
10741074

10751075

1076+
@pytest.mark.parametrize("async_op", [False, True])
1077+
def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
1078+
client = _make_client()
1079+
client._kernel_session = MagicMock()
1080+
cursor = MagicMock(arraysize=100, buffer_size_bytes=1024)
1081+
statements = [MagicMock(), MagicMock()]
1082+
client._kernel_session.statement.side_effect = statements
1083+
1084+
for stmt, enabled in zip(statements, [True, False]):
1085+
stmt.execute.return_value = MagicMock(
1086+
statement_id="stmt-id",
1087+
arrow_schema=MagicMock(return_value=pa.schema([("x", pa.int64())])),
1088+
)
1089+
stmt.submit.return_value.statement_id = "stmt-id"
1090+
client.execute_command(
1091+
operation="SELECT 1",
1092+
session_id=MagicMock(),
1093+
max_rows=1,
1094+
max_bytes=1,
1095+
lz4_compression=enabled,
1096+
cursor=cursor,
1097+
use_cloud_fetch=True,
1098+
parameters=[],
1099+
async_op=async_op,
1100+
enforce_embedded_schema_correctness=False,
1101+
)
1102+
1103+
dispatch = call.submit() if async_op else call.execute()
1104+
stmt.set_lz4_compression.assert_called_once_with(enabled)
1105+
assert stmt.method_calls.index(call.set_lz4_compression(enabled)) < (
1106+
stmt.method_calls.index(dispatch)
1107+
)
1108+
1109+
10761110
# ---------------------------------------------------------------------------
10771111
# Staging / volume operations — fail loud (not silently no-op)
10781112
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)