Skip to content

Commit 14c5625

Browse files
make description mandatory, not Optional
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 4d10dcc commit 14c5625

File tree

6 files changed

+10
-24
lines changed

6 files changed

+10
-24
lines changed

src/databricks/sql/backend/sea/backend.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def get_allowed_session_configurations() -> List[str]:
290290

291291
def _extract_description_from_manifest(
292292
self, manifest: ResultManifest
293-
) -> Optional[List]:
293+
) -> List[Tuple]:
294294
"""
295295
Extract column description from a manifest object, in the format defined by
296296
the spec: https://peps.python.org/pep-0249/#description
@@ -299,15 +299,12 @@ def _extract_description_from_manifest(
299299
manifest: The ResultManifest object containing schema information
300300
301301
Returns:
302-
Optional[List]: A list of column tuples or None if no columns are found
302+
List[Tuple]: A list of column tuples
303303
"""
304304

305305
schema_data = manifest.schema
306306
columns_data = schema_data.get("columns", [])
307307

308-
if not columns_data:
309-
return None
310-
311308
columns = []
312309
for col_data in columns_data:
313310
# Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
@@ -323,7 +320,7 @@ def _extract_description_from_manifest(
323320
)
324321
)
325322

326-
return columns if columns else None
323+
return columns
327324

328325
def _results_message_to_execute_response(
329326
self, response: GetStatementResponse

src/databricks/sql/backend/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class ExecuteResponse:
423423

424424
command_id: CommandId
425425
status: CommandState
426-
description: Optional[List[Tuple]] = None
426+
description: List[Tuple]
427427
has_been_closed_server_side: bool = False
428428
lz4_compressed: bool = True
429429
is_staging_operation: bool = False

src/databricks/sql/result_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from abc import ABC, abstractmethod
4-
from typing import List, Optional, TYPE_CHECKING
4+
from typing import List, Optional, TYPE_CHECKING, Tuple
55

66
import logging
77
import pandas
@@ -50,7 +50,7 @@ def __init__(
5050
has_been_closed_server_side: bool = False,
5151
is_direct_results: bool = False,
5252
results_queue=None,
53-
description=None,
53+
description: List[Tuple] = [],
5454
is_staging_operation: bool = False,
5555
lz4_compressed: bool = False,
5656
arrow_schema_bytes: Optional[bytes] = None,

src/databricks/sql/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def build_queue(
6161
max_download_threads: int,
6262
ssl_options: SSLOptions,
6363
lz4_compressed: bool = True,
64-
description: Optional[List[Tuple]] = None,
64+
description: List[Tuple] = [],
6565
) -> ResultSetQueue:
6666
"""
6767
Factory method to build a result set queue.
@@ -117,7 +117,7 @@ def build_queue(
117117
sea_result_data: ResultData,
118118
manifest: Optional[ResultManifest],
119119
statement_id: str,
120-
description: Optional[List[Tuple[Any, ...]]] = None,
120+
description: List[Tuple] = [],
121121
schema_bytes: Optional[bytes] = None,
122122
max_download_threads: Optional[int] = None,
123123
sea_client: Optional[SeaDatabricksClient] = None,
@@ -274,7 +274,7 @@ def __init__(
274274
start_row_offset: int = 0,
275275
result_links: Optional[List[TSparkArrowResultLink]] = None,
276276
lz4_compressed: bool = True,
277-
description: Optional[List[Tuple]] = None,
277+
description: List[Tuple] = [],
278278
):
279279
"""
280280
A queue-like wrapper over CloudFetch arrow batches.

tests/unit/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def test_closing_connection_closes_commands(self, mock_thrift_client_class):
100100
)
101101
mock_execute_response.has_been_closed_server_side = closed
102102
mock_execute_response.is_staging_operation = False
103+
mock_execute_response.description = []
103104

104105
# Mock the backend that will be used by the real ThriftResultSet
105106
mock_backend = Mock(spec=ThriftDatabricksClient)

tests/unit/test_sea_backend.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -621,18 +621,6 @@ def test_utility_methods(self, sea_client):
621621
assert description[1][1] == "INT" # type_code
622622
assert description[1][6] is False # null_ok
623623

624-
# Test _extract_description_from_manifest with empty columns
625-
empty_manifest = MagicMock()
626-
empty_manifest.schema = {"columns": []}
627-
assert sea_client._extract_description_from_manifest(empty_manifest) is None
628-
629-
# Test _extract_description_from_manifest with no columns key
630-
no_columns_manifest = MagicMock()
631-
no_columns_manifest.schema = {}
632-
assert (
633-
sea_client._extract_description_from_manifest(no_columns_manifest) is None
634-
)
635-
636624
def test_results_message_to_execute_response_is_staging_operation(self, sea_client):
637625
"""Test that is_staging_operation is correctly set from manifest.is_volume_operation."""
638626
# Test when is_volume_operation is True

0 commit comments

Comments
 (0)