Skip to content

Commit f5ceea9

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

4 files changed

Lines changed: 42 additions & 9 deletions

File tree

‎CONNECTION_PARAMETERS.md‎

Lines changed: 5 additions & 7 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,15 +204,13 @@ 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`.
213+
7. `force_enable_telemetry`.
216214
9. `_port` and `_connection_uri`.
217215
10. `_pool_connections` and `_proxy_auth_method` do not configure the
218216
kernel-owned network stack.

‎KERNEL_REV‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5c3a909771f749174567af074bfe18c24a335f5c
1+
4691f70cda81ad2b22c419d876d7aebbdbf878fe

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ def execute_command(
666666
try:
667667
stmt.set_sql(operation)
668668
stmt.set_row_limit(row_limit)
669+
stmt.set_lz4_compression(lz4_compression)
669670
if query_tags:
670671
# Per-statement query tags. The kernel serialises the
671672
# 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

@@ -1009,6 +1009,40 @@ def test_execute_command_forwards_row_limit(row_limit):
10091009
stmt.set_row_limit.assert_called_once_with(row_limit)
10101010

10111011

1012+
@pytest.mark.parametrize("async_op", [False, True])
1013+
def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
1014+
client = _make_client()
1015+
client._kernel_session = MagicMock()
1016+
cursor = MagicMock(arraysize=100, buffer_size_bytes=1024)
1017+
statements = [MagicMock(), MagicMock()]
1018+
client._kernel_session.statement.side_effect = statements
1019+
1020+
for stmt, enabled in zip(statements, [True, False]):
1021+
stmt.execute.return_value = MagicMock(
1022+
statement_id="stmt-id",
1023+
arrow_schema=MagicMock(return_value=pa.schema([("x", pa.int64())])),
1024+
)
1025+
stmt.submit.return_value.statement_id = "stmt-id"
1026+
client.execute_command(
1027+
operation="SELECT 1",
1028+
session_id=MagicMock(),
1029+
max_rows=1,
1030+
max_bytes=1,
1031+
lz4_compression=enabled,
1032+
cursor=cursor,
1033+
use_cloud_fetch=True,
1034+
parameters=[],
1035+
async_op=async_op,
1036+
enforce_embedded_schema_correctness=False,
1037+
)
1038+
1039+
dispatch = call.submit() if async_op else call.execute()
1040+
stmt.set_lz4_compression.assert_called_once_with(enabled)
1041+
assert stmt.method_calls.index(call.set_lz4_compression(enabled)) < (
1042+
stmt.method_calls.index(dispatch)
1043+
)
1044+
1045+
10121046
# ---------------------------------------------------------------------------
10131047
# Staging / volume operations — fail loud (not silently no-op)
10141048
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)