Skip to content

Commit 36ab59b

Browse files
move description extraction to helper func
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent efe3881 commit 36ab59b

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

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

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,43 @@ def get_allowed_session_configurations() -> List[str]:
282282
"""
283283
return list(ALLOWED_SESSION_CONF_TO_DEFAULT_VALUES_MAP.keys())
284284

285+
def _extract_description_from_manifest(self, manifest_obj) -> Optional[List]:
286+
"""
287+
Extract column description from a manifest object.
288+
289+
Args:
290+
manifest_obj: The ResultManifest object containing schema information
291+
292+
Returns:
293+
Optional[List]: A list of column tuples or None if no columns are found
294+
"""
295+
296+
schema_data = manifest_obj.schema
297+
columns_data = schema_data.get("columns", [])
298+
299+
if not columns_data:
300+
return None
301+
302+
columns = []
303+
for col_data in columns_data:
304+
if not isinstance(col_data, dict):
305+
continue
306+
307+
# Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
308+
columns.append(
309+
(
310+
col_data.get("name", ""), # name
311+
col_data.get("type_name", ""), # type_code
312+
None, # display_size (not provided by SEA)
313+
None, # internal_size (not provided by SEA)
314+
col_data.get("precision"), # precision
315+
col_data.get("scale"), # scale
316+
col_data.get("nullable", True), # null_ok
317+
)
318+
)
319+
320+
return columns if columns else None
321+
285322
def _results_message_to_execute_response(self, sea_response, command_id):
286323
"""
287324
Convert a SEA response to an ExecuteResponse and extract result data.
@@ -301,28 +338,7 @@ def _results_message_to_execute_response(self, sea_response, command_id):
301338
result_data_obj = parse_result(sea_response)
302339

303340
# Extract description from manifest schema
304-
description = None
305-
schema_data = manifest_obj.schema
306-
columns_data = schema_data.get("columns", [])
307-
if columns_data:
308-
columns = []
309-
for col_data in columns_data:
310-
if not isinstance(col_data, dict):
311-
continue
312-
313-
# Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
314-
columns.append(
315-
(
316-
col_data.get("name", ""), # name
317-
col_data.get("type_name", ""), # type_code
318-
None, # display_size (not provided by SEA)
319-
None, # internal_size (not provided by SEA)
320-
col_data.get("precision"), # precision
321-
col_data.get("scale"), # scale
322-
col_data.get("nullable", True), # null_ok
323-
)
324-
)
325-
description = columns if columns else None
341+
description = self._extract_description_from_manifest(manifest_obj)
326342

327343
# Check for compression
328344
lz4_compressed = manifest_obj.result_compression == "LZ4_FRAME"

0 commit comments

Comments
 (0)