Skip to content

Commit 4ed87de

Browse files
fix(kernel): preserve compression option truthiness
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
1 parent f5ceea9 commit 4ed87de

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎CONNECTION_PARAMETERS.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ are forwarded when supported by the installed kernel binding.
211211
`_retry_dangerous_codes`, `_respect_server_retry_after_header`,
212212
`_retry_max_redirects`, `_enable_v3_retries`.
213213
7. `force_enable_telemetry`.
214-
9. `_port` and `_connection_uri`.
215-
10. `_pool_connections` and `_proxy_auth_method` do not configure the
216-
kernel-owned network stack.
214+
8. `_port` and `_connection_uri`.
215+
9. `_pool_connections` and `_proxy_auth_method` do not configure the
216+
kernel-owned network stack.
217217

218218
### Supported on Kernel, missing / ignored on Thrift
219219

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +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)
669+
stmt.set_lz4_compression(bool(lz4_compression))
670670
if query_tags:
671671
# Per-statement query tags. The kernel serialises the
672672
# dict (None value -> bare key) into the SEA

‎tests/unit/test_kernel_client.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,10 +1014,11 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
10141014
client = _make_client()
10151015
client._kernel_session = MagicMock()
10161016
cursor = MagicMock(arraysize=100, buffer_size_bytes=1024)
1017-
statements = [MagicMock(), MagicMock()]
1017+
cases = [(True, True), (False, False), (0, False)]
1018+
statements = [MagicMock() for _ in cases]
10181019
client._kernel_session.statement.side_effect = statements
10191020

1020-
for stmt, enabled in zip(statements, [True, False]):
1021+
for stmt, (value, expected) in zip(statements, cases):
10211022
stmt.execute.return_value = MagicMock(
10221023
statement_id="stmt-id",
10231024
arrow_schema=MagicMock(return_value=pa.schema([("x", pa.int64())])),
@@ -1028,7 +1029,7 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
10281029
session_id=MagicMock(),
10291030
max_rows=1,
10301031
max_bytes=1,
1031-
lz4_compression=enabled,
1032+
lz4_compression=value,
10321033
cursor=cursor,
10331034
use_cloud_fetch=True,
10341035
parameters=[],
@@ -1037,8 +1038,9 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
10371038
)
10381039

10391040
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)) < (
1041+
stmt.set_lz4_compression.assert_called_once_with(expected)
1042+
assert stmt.set_lz4_compression.call_args.args[0] is expected
1043+
assert stmt.method_calls.index(call.set_lz4_compression(expected)) < (
10421044
stmt.method_calls.index(dispatch)
10431045
)
10441046

0 commit comments

Comments
 (0)