Skip to content

Commit 460f3fe

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

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
@@ -678,7 +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)
681+
stmt.set_lz4_compression(bool(lz4_compression))
682682
if query_tags:
683683
# Per-statement query tags. The kernel serialises the
684684
# 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
@@ -1078,10 +1078,11 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
10781078
client = _make_client()
10791079
client._kernel_session = MagicMock()
10801080
cursor = MagicMock(arraysize=100, buffer_size_bytes=1024)
1081-
statements = [MagicMock(), MagicMock()]
1081+
cases = [(True, True), (False, False), (0, False)]
1082+
statements = [MagicMock() for _ in cases]
10821083
client._kernel_session.statement.side_effect = statements
10831084

1084-
for stmt, enabled in zip(statements, [True, False]):
1085+
for stmt, (value, expected) in zip(statements, cases):
10851086
stmt.execute.return_value = MagicMock(
10861087
statement_id="stmt-id",
10871088
arrow_schema=MagicMock(return_value=pa.schema([("x", pa.int64())])),
@@ -1092,7 +1093,7 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
10921093
session_id=MagicMock(),
10931094
max_rows=1,
10941095
max_bytes=1,
1095-
lz4_compression=enabled,
1096+
lz4_compression=value,
10961097
cursor=cursor,
10971098
use_cloud_fetch=True,
10981099
parameters=[],
@@ -1101,8 +1102,9 @@ def test_execute_command_forwards_lz4_compression_before_dispatch(async_op):
11011102
)
11021103

11031104
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)) < (
1105+
stmt.set_lz4_compression.assert_called_once_with(expected)
1106+
assert stmt.set_lz4_compression.call_args.args[0] is expected
1107+
assert stmt.method_calls.index(call.set_lz4_compression(expected)) < (
11061108
stmt.method_calls.index(dispatch)
11071109
)
11081110

0 commit comments

Comments
 (0)