Skip to content

Commit 69ea238

Browse files
re-introduce get_schema_desc
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 31e6c83 commit 69ea238

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/databricks/sql/backend/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ def __init__(
299299
self.guid = guid
300300
self.secret = secret
301301

302-
303302
def __str__(self) -> str:
304303
"""
305304
Return a string representation of the CommandId.

src/databricks/sql/result_set.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ def __init__(
5959
has_been_closed_server_side: Whether the command has been closed on the server
6060
has_more_rows: Whether the command has more rows
6161
results_queue: The results queue
62-
description: column description of the results
62+
description: column description of the results
6363
is_staging_operation: Whether the command is a staging operation
6464
"""
6565

6666
self.connection = connection
67-
self.backend = backend
67+
self.backend = backend
6868
self.arraysize = arraysize
6969
self.buffer_size_bytes = buffer_size_bytes
7070
self._next_row_index = 0
@@ -400,6 +400,23 @@ def fetchmany(self, size: int) -> List[Row]:
400400
else:
401401
return self._convert_arrow_table(self.fetchmany_arrow(size))
402402

403+
@staticmethod
404+
def _get_schema_description(table_schema_message):
405+
"""
406+
Takes a TableSchema message and returns a description 7-tuple as specified by PEP-249
407+
"""
408+
409+
def map_col_type(type_):
410+
if type_.startswith("decimal"):
411+
return "decimal"
412+
else:
413+
return type_
414+
415+
return [
416+
(column.name, map_col_type(column.datatype), None, None, None, None, None)
417+
for column in table_schema_message.columns
418+
]
419+
403420

404421
class SeaResultSet(ResultSet):
405422
"""ResultSet implementation for SEA backend."""

0 commit comments

Comments
 (0)