Skip to content

Commit 381e243

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

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +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)
688+
stmt.set_lz4_compression(bool(lz4_compression))
689689
if query_tags:
690690
# Per-statement query tags. The kernel serialises the
691691
# 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
@@ -1144,10 +1144,11 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
11441144
client = _make_client()
11451145
client._kernel_session = MagicMock()
11461146
cursor = MagicMock(arraysize=100, buffer_size_bytes=1024)
1147-
statements = [MagicMock(), MagicMock()]
1147+
cases = [(True, True), (False, False), (0, False)]
1148+
statements = [MagicMock() for _ in cases]
11481149
client._kernel_session.statement.side_effect = statements
11491150

1150-
for stmt, enabled in zip(statements, [True, False]):
1151+
for stmt, (value, expected) in zip(statements, cases):
11511152
stmt.execute.return_value = MagicMock(
11521153
statement_id="stmt-id",
11531154
arrow_schema=MagicMock(return_value=pa.schema([("x", pa.int64())])),
@@ -1158,7 +1159,7 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
11581159
session_id=MagicMock(),
11591160
max_rows=1,
11601161
max_bytes=1,
1161-
lz4_compression=enabled,
1162+
lz4_compression=value,
11621163
cursor=cursor,
11631164
use_cloud_fetch=True,
11641165
parameters=[],
@@ -1167,8 +1168,9 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
11671168
)
11681169

11691170
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)) < (
1171+
stmt.set_lz4_compression.assert_called_once_with(expected)
1172+
assert stmt.set_lz4_compression.call_args.args[0] is expected
1173+
assert stmt.method_calls.index(call.set_lz4_compression(expected)) < (
11721174
stmt.method_calls.index(dispatch)
11731175
)
11741176

0 commit comments

Comments
 (0)