Skip to content

Commit fd52356

Browse files
remove un-necessary test changes
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 6229848 commit fd52356

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

src/databricks/sql/backend/types.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,9 @@ class ExecuteResponse:
423423

424424
command_id: CommandId
425425
status: CommandState
426-
description: Optional[
427-
List[Tuple[str, str, None, None, Optional[int], Optional[int], bool]]
428-
] = None
429-
has_more_rows: bool = False
430-
results_queue: Optional[Any] = None
426+
description: Optional[List[Tuple]] = None
431427
has_been_closed_server_side: bool = False
432428
lz4_compressed: bool = True
433429
is_staging_operation: bool = False
430+
arrow_schema_bytes: Optional[bytes] = None
431+
result_format: Optional[Any] = None

tests/unit/test_client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def new(cls):
4848
is_staging_operation=False,
4949
command_id=None,
5050
has_been_closed_server_side=True,
51-
has_more_rows=True,
51+
is_direct_results=True,
5252
lz4_compressed=True,
5353
arrow_schema_bytes=b"schema",
5454
)
@@ -104,6 +104,7 @@ def test_closing_connection_closes_commands(self, mock_thrift_client_class):
104104
# Mock the backend that will be used by the real ThriftResultSet
105105
mock_backend = Mock(spec=ThriftDatabricksClient)
106106
mock_backend.staging_allowed_local_path = None
107+
mock_backend.fetch_results.return_value = (Mock(), False)
107108

108109
# Configure the decorator's mock to return our specific mock_backend
109110
mock_thrift_client_class.return_value = mock_backend
@@ -184,6 +185,7 @@ def test_arraysize_buffer_size_passthrough(
184185
def test_closing_result_set_with_closed_connection_soft_closes_commands(self):
185186
mock_connection = Mock()
186187
mock_backend = Mock()
188+
mock_backend.fetch_results.return_value = (Mock(), False)
187189

188190
result_set = ThriftResultSet(
189191
connection=mock_connection,
@@ -210,6 +212,7 @@ def test_closing_result_set_hard_closes_commands(self):
210212
mock_session.open = True
211213
type(mock_connection).session = PropertyMock(return_value=mock_session)
212214

215+
mock_thrift_backend.fetch_results.return_value = (Mock(), False)
213216
result_set = ThriftResultSet(
214217
mock_connection, mock_results_response, mock_thrift_backend
215218
)
@@ -254,7 +257,10 @@ def test_closed_cursor_doesnt_allow_operations(self):
254257
self.assertIn("closed", e.msg)
255258

256259
def test_negative_fetch_throws_exception(self):
257-
result_set = ThriftResultSet(Mock(), Mock(), Mock())
260+
mock_backend = Mock()
261+
mock_backend.fetch_results.return_value = (Mock(), False)
262+
263+
result_set = ThriftResultSet(Mock(), Mock(), mock_backend)
258264

259265
with self.assertRaises(ValueError) as e:
260266
result_set.fetchmany(-1)
@@ -472,7 +478,6 @@ def make_fake_row_slice(n_rows):
472478
mock_aq = Mock()
473479
mock_aq.next_n_rows.side_effect = make_fake_row_slice
474480
mock_thrift_backend.execute_command.return_value.arrow_queue = mock_aq
475-
mock_thrift_backend.fetch_results.return_value = (mock_aq, True)
476481

477482
cursor = client.Cursor(Mock(), mock_thrift_backend)
478483
cursor.execute("foo")

tests/unit/test_fetches.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,30 @@ def make_dummy_result_set_from_initial_results(initial_results):
4040
# If the initial results have been set, then we should never try and fetch more
4141
schema, arrow_table = FetchTests.make_arrow_table(initial_results)
4242
arrow_queue = ArrowQueue(arrow_table, len(initial_results), 0)
43+
44+
# Create a mock backend that will return the queue when _fill_results_buffer is called
45+
mock_thrift_backend = Mock(spec=ThriftDatabricksClient)
46+
mock_thrift_backend.fetch_results.return_value = (arrow_queue, False)
47+
48+
num_cols = len(initial_results[0]) if initial_results else 0
49+
description = [
50+
(f"col{col_id}", "integer", None, None, None, None, None)
51+
for col_id in range(num_cols)
52+
]
53+
4354
rs = ThriftResultSet(
4455
connection=Mock(),
4556
execute_response=ExecuteResponse(
4657
command_id=None,
4758
status=None,
4859
has_been_closed_server_side=True,
49-
has_more_rows=False,
50-
description=Mock(),
51-
lz4_compressed=Mock(),
52-
results_queue=arrow_queue,
60+
description=description,
61+
lz4_compressed=True,
5362
is_staging_operation=False,
5463
),
55-
thrift_client=None,
64+
thrift_client=mock_thrift_backend,
65+
t_row_set=None,
5666
)
57-
num_cols = len(initial_results[0]) if initial_results else 0
58-
rs.description = [
59-
(f"col{col_id}", "integer", None, None, None, None, None)
60-
for col_id in range(num_cols)
61-
]
6267
return rs
6368

6469
@staticmethod
@@ -85,19 +90,19 @@ def fetch_results(
8590
mock_thrift_backend.fetch_results = fetch_results
8691
num_cols = len(batch_list[0][0]) if batch_list and batch_list[0] else 0
8792

93+
description = [
94+
(f"col{col_id}", "integer", None, None, None, None, None)
95+
for col_id in range(num_cols)
96+
]
97+
8898
rs = ThriftResultSet(
8999
connection=Mock(),
90100
execute_response=ExecuteResponse(
91101
command_id=None,
92102
status=None,
93103
has_been_closed_server_side=False,
94-
has_more_rows=True,
95-
description=[
96-
(f"col{col_id}", "integer", None, None, None, None, None)
97-
for col_id in range(num_cols)
98-
],
99-
lz4_compressed=Mock(),
100-
results_queue=None,
104+
description=description,
105+
lz4_compressed=True,
101106
is_staging_operation=False,
102107
),
103108
thrift_client=mock_thrift_backend,

tests/unit/test_fetches_bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def make_dummy_result_set_from_initial_results(arrow_table):
3636
execute_response=ExecuteResponse(
3737
status=None,
3838
has_been_closed_server_side=True,
39-
has_more_rows=False,
39+
is_direct_results=False,
4040
description=Mock(),
4141
command_id=None,
4242
arrow_queue=arrow_queue,

0 commit comments

Comments
 (0)