Skip to content

Commit 36b9cfb

Browse files
has_more_rows -> is_direct_results
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 8cbeb08 commit 36b9cfb

File tree

5 files changed

+44
-36
lines changed

5 files changed

+44
-36
lines changed

src/databricks/sql/backend/thrift_backend.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def _results_message_to_execute_response(self, resp, operation_state):
758758
direct_results = resp.directResults
759759
has_been_closed_server_side = direct_results and direct_results.closeOperation
760760

761-
has_more_rows = (
761+
is_direct_results = (
762762
(not direct_results)
763763
or (not direct_results.resultSet)
764764
or direct_results.resultSet.hasMoreRows
@@ -796,7 +796,7 @@ def _results_message_to_execute_response(self, resp, operation_state):
796796
result_format=t_result_set_metadata_resp.resultFormat,
797797
)
798798

799-
return execute_response, has_more_rows
799+
return execute_response, is_direct_results
800800

801801
def get_execution_result(
802802
self, command_id: CommandId, cursor: "Cursor"
@@ -838,7 +838,7 @@ def get_execution_result(
838838

839839
lz4_compressed = t_result_set_metadata_resp.lz4Compressed
840840
is_staging_operation = t_result_set_metadata_resp.isStagingOperation
841-
has_more_rows = resp.hasMoreRows
841+
is_direct_results = resp.hasMoreRows
842842

843843
status = self.get_query_state(command_id)
844844

@@ -863,7 +863,7 @@ def get_execution_result(
863863
t_row_set=resp.results,
864864
max_download_threads=self.max_download_threads,
865865
ssl_options=self._ssl_options,
866-
has_more_rows=has_more_rows,
866+
is_direct_results=is_direct_results,
867867
)
868868

869869
def _wait_until_command_done(self, op_handle, initial_operation_status_resp):
@@ -976,7 +976,7 @@ def execute_command(
976976
self._handle_execute_response_async(resp, cursor)
977977
return None
978978
else:
979-
execute_response, has_more_rows = self._handle_execute_response(
979+
execute_response, is_direct_results = self._handle_execute_response(
980980
resp, cursor
981981
)
982982

@@ -994,7 +994,7 @@ def execute_command(
994994
t_row_set=t_row_set,
995995
max_download_threads=self.max_download_threads,
996996
ssl_options=self._ssl_options,
997-
has_more_rows=has_more_rows,
997+
is_direct_results=is_direct_results,
998998
)
999999

10001000
def get_catalogs(
@@ -1016,7 +1016,9 @@ def get_catalogs(
10161016
)
10171017
resp = self.make_request(self._client.GetCatalogs, req)
10181018

1019-
execute_response, has_more_rows = self._handle_execute_response(resp, cursor)
1019+
execute_response, is_direct_results = self._handle_execute_response(
1020+
resp, cursor
1021+
)
10201022

10211023
t_row_set = None
10221024
if resp.directResults and resp.directResults.resultSet:
@@ -1032,7 +1034,7 @@ def get_catalogs(
10321034
t_row_set=t_row_set,
10331035
max_download_threads=self.max_download_threads,
10341036
ssl_options=self._ssl_options,
1035-
has_more_rows=has_more_rows,
1037+
is_direct_results=is_direct_results,
10361038
)
10371039

10381040
def get_schemas(
@@ -1058,7 +1060,9 @@ def get_schemas(
10581060
)
10591061
resp = self.make_request(self._client.GetSchemas, req)
10601062

1061-
execute_response, has_more_rows = self._handle_execute_response(resp, cursor)
1063+
execute_response, is_direct_results = self._handle_execute_response(
1064+
resp, cursor
1065+
)
10621066

10631067
t_row_set = None
10641068
if resp.directResults and resp.directResults.resultSet:
@@ -1074,7 +1078,7 @@ def get_schemas(
10741078
t_row_set=t_row_set,
10751079
max_download_threads=self.max_download_threads,
10761080
ssl_options=self._ssl_options,
1077-
has_more_rows=has_more_rows,
1081+
is_direct_results=is_direct_results,
10781082
)
10791083

10801084
def get_tables(
@@ -1104,7 +1108,9 @@ def get_tables(
11041108
)
11051109
resp = self.make_request(self._client.GetTables, req)
11061110

1107-
execute_response, has_more_rows = self._handle_execute_response(resp, cursor)
1111+
execute_response, is_direct_results = self._handle_execute_response(
1112+
resp, cursor
1113+
)
11081114

11091115
t_row_set = None
11101116
if resp.directResults and resp.directResults.resultSet:
@@ -1120,7 +1126,7 @@ def get_tables(
11201126
t_row_set=t_row_set,
11211127
max_download_threads=self.max_download_threads,
11221128
ssl_options=self._ssl_options,
1123-
has_more_rows=has_more_rows,
1129+
is_direct_results=is_direct_results,
11241130
)
11251131

11261132
def get_columns(
@@ -1150,7 +1156,9 @@ def get_columns(
11501156
)
11511157
resp = self.make_request(self._client.GetColumns, req)
11521158

1153-
execute_response, has_more_rows = self._handle_execute_response(resp, cursor)
1159+
execute_response, is_direct_results = self._handle_execute_response(
1160+
resp, cursor
1161+
)
11541162

11551163
t_row_set = None
11561164
if resp.directResults and resp.directResults.resultSet:
@@ -1166,7 +1174,7 @@ def get_columns(
11661174
t_row_set=t_row_set,
11671175
max_download_threads=self.max_download_threads,
11681176
ssl_options=self._ssl_options,
1169-
has_more_rows=has_more_rows,
1177+
is_direct_results=is_direct_results,
11701178
)
11711179

11721180
def _handle_execute_response(self, resp, cursor):

src/databricks/sql/result_set.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(
4141
command_id: CommandId,
4242
status: CommandState,
4343
has_been_closed_server_side: bool = False,
44-
has_more_rows: bool = False,
44+
is_direct_results: bool = False,
4545
results_queue=None,
4646
description=None,
4747
is_staging_operation: bool = False,
@@ -57,7 +57,7 @@ def __init__(
5757
command_id: The command ID
5858
status: The command status
5959
has_been_closed_server_side: Whether the command has been closed on the server
60-
has_more_rows: Whether the command has more rows
60+
is_direct_results: Whether the command has more rows
6161
results_queue: The results queue
6262
description: column description of the results
6363
is_staging_operation: Whether the command is a staging operation
@@ -72,7 +72,7 @@ def __init__(
7272
self.command_id = command_id
7373
self.status = status
7474
self.has_been_closed_server_side = has_been_closed_server_side
75-
self.has_more_rows = has_more_rows
75+
self.is_direct_results = is_direct_results
7676
self.results = results_queue
7777
self._is_staging_operation = is_staging_operation
7878

@@ -160,7 +160,7 @@ def __init__(
160160
t_row_set=None,
161161
max_download_threads: int = 10,
162162
ssl_options=None,
163-
has_more_rows: bool = True,
163+
is_direct_results: bool = True,
164164
):
165165
"""
166166
Initialize a ThriftResultSet with direct access to the ThriftDatabricksClient.
@@ -175,7 +175,7 @@ def __init__(
175175
t_row_set: The TRowSet containing result data (if available)
176176
max_download_threads: Maximum number of download threads for cloud fetch
177177
ssl_options: SSL options for cloud fetch
178-
has_more_rows: Whether there are more rows to fetch
178+
is_direct_results: Whether there are more rows to fetch
179179
"""
180180
# Initialize ThriftResultSet-specific attributes
181181
self._arrow_schema_bytes = execute_response.arrow_schema_bytes
@@ -207,7 +207,7 @@ def __init__(
207207
command_id=execute_response.command_id,
208208
status=execute_response.status,
209209
has_been_closed_server_side=execute_response.has_been_closed_server_side,
210-
has_more_rows=has_more_rows,
210+
is_direct_results=is_direct_results,
211211
results_queue=results_queue,
212212
description=execute_response.description,
213213
is_staging_operation=execute_response.is_staging_operation,
@@ -218,7 +218,7 @@ def __init__(
218218
self._fill_results_buffer()
219219

220220
def _fill_results_buffer(self):
221-
results, has_more_rows = self.backend.fetch_results(
221+
results, is_direct_results = self.backend.fetch_results(
222222
command_id=self.command_id,
223223
max_rows=self.arraysize,
224224
max_bytes=self.buffer_size_bytes,
@@ -229,7 +229,7 @@ def _fill_results_buffer(self):
229229
use_cloud_fetch=self._use_cloud_fetch,
230230
)
231231
self.results = results
232-
self.has_more_rows = has_more_rows
232+
self.is_direct_results = is_direct_results
233233

234234
def _convert_columnar_table(self, table):
235235
column_names = [c[0] for c in self.description]
@@ -313,7 +313,7 @@ def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
313313
while (
314314
n_remaining_rows > 0
315315
and not self.has_been_closed_server_side
316-
and self.has_more_rows
316+
and self.is_direct_results
317317
):
318318
self._fill_results_buffer()
319319
partial_results = self.results.next_n_rows(n_remaining_rows)
@@ -338,7 +338,7 @@ def fetchmany_columnar(self, size: int):
338338
while (
339339
n_remaining_rows > 0
340340
and not self.has_been_closed_server_side
341-
and self.has_more_rows
341+
and self.is_direct_results
342342
):
343343
self._fill_results_buffer()
344344
partial_results = self.results.next_n_rows(n_remaining_rows)
@@ -353,7 +353,7 @@ def fetchall_arrow(self) -> "pyarrow.Table":
353353
results = self.results.remaining_rows()
354354
self._next_row_index += results.num_rows
355355

356-
while not self.has_been_closed_server_side and self.has_more_rows:
356+
while not self.has_been_closed_server_side and self.is_direct_results:
357357
self._fill_results_buffer()
358358
partial_results = self.results.remaining_rows()
359359
if isinstance(results, ColumnTable) and isinstance(
@@ -379,7 +379,7 @@ def fetchall_columnar(self):
379379
results = self.results.remaining_rows()
380380
self._next_row_index += results.num_rows
381381

382-
while not self.has_been_closed_server_side and self.has_more_rows:
382+
while not self.has_been_closed_server_side and self.is_direct_results:
383383
self._fill_results_buffer()
384384
partial_results = self.results.remaining_rows()
385385
results = self.merge_columnar(results, partial_results)

tests/unit/test_client.py

Lines changed: 1 addition & 1 deletion
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
)

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,

tests/unit/test_thrift_backend.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,10 +1004,10 @@ def test_fall_back_to_hive_schema_if_no_arrow_schema(self, tcli_service_class):
10041004
def test_handle_execute_response_reads_has_more_rows_in_direct_results(
10051005
self, tcli_service_class, build_queue
10061006
):
1007-
for has_more_rows, resp_type in itertools.product(
1007+
for is_direct_results, resp_type in itertools.product(
10081008
[True, False], self.execute_response_types
10091009
):
1010-
with self.subTest(has_more_rows=has_more_rows, resp_type=resp_type):
1010+
with self.subTest(is_direct_results=is_direct_results, resp_type=resp_type):
10111011
tcli_service_instance = tcli_service_class.return_value
10121012
results_mock = Mock()
10131013
results_mock.startRowOffset = 0
@@ -1019,7 +1019,7 @@ def test_handle_execute_response_reads_has_more_rows_in_direct_results(
10191019
resultSetMetadata=self.metadata_resp,
10201020
resultSet=ttypes.TFetchResultsResp(
10211021
status=self.okay_status,
1022-
hasMoreRows=has_more_rows,
1022+
hasMoreRows=is_direct_results,
10231023
results=results_mock,
10241024
),
10251025
closeOperation=Mock(),
@@ -1040,7 +1040,7 @@ def test_handle_execute_response_reads_has_more_rows_in_direct_results(
10401040
has_more_rows_result,
10411041
) = thrift_backend._handle_execute_response(execute_resp, Mock())
10421042

1043-
self.assertEqual(has_more_rows, has_more_rows_result)
1043+
self.assertEqual(is_direct_results, has_more_rows_result)
10441044

10451045
@patch(
10461046
"databricks.sql.utils.ResultSetQueueFactory.build_queue", return_value=Mock()
@@ -1049,10 +1049,10 @@ def test_handle_execute_response_reads_has_more_rows_in_direct_results(
10491049
def test_handle_execute_response_reads_has_more_rows_in_result_response(
10501050
self, tcli_service_class, build_queue
10511051
):
1052-
for has_more_rows, resp_type in itertools.product(
1052+
for is_direct_results, resp_type in itertools.product(
10531053
[True, False], self.execute_response_types
10541054
):
1055-
with self.subTest(has_more_rows=has_more_rows, resp_type=resp_type):
1055+
with self.subTest(is_direct_results=is_direct_results, resp_type=resp_type):
10561056
tcli_service_instance = tcli_service_class.return_value
10571057
results_mock = MagicMock()
10581058
results_mock.startRowOffset = 0
@@ -1065,7 +1065,7 @@ def test_handle_execute_response_reads_has_more_rows_in_result_response(
10651065

10661066
fetch_results_resp = ttypes.TFetchResultsResp(
10671067
status=self.okay_status,
1068-
hasMoreRows=has_more_rows,
1068+
hasMoreRows=is_direct_results,
10691069
results=results_mock,
10701070
resultSetMetadata=ttypes.TGetResultSetMetadataResp(
10711071
resultFormat=ttypes.TSparkRowSetType.ARROW_BASED_SET
@@ -1098,7 +1098,7 @@ def test_handle_execute_response_reads_has_more_rows_in_result_response(
10981098
description=Mock(),
10991099
)
11001100

1101-
self.assertEqual(has_more_rows, has_more_rows_resp)
1101+
self.assertEqual(is_direct_results, has_more_rows_resp)
11021102

11031103
@patch("databricks.sql.backend.thrift_backend.TCLIService.Client", autospec=True)
11041104
def test_arrow_batches_row_count_are_respected(self, tcli_service_class):

0 commit comments

Comments
 (0)