Skip to content

Commit b3273c7

Browse files
remove complex type conversion
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 3944e39 commit b3273c7

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

src/databricks/sql/result_set.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -600,43 +600,6 @@ def fetchall_json(self) -> List:
600600

601601
return results
602602

603-
def _convert_complex_types_to_string(
604-
self, rows: "pyarrow.Table"
605-
) -> "pyarrow.Table":
606-
"""
607-
Convert complex types (array, struct, map) to string representation.
608-
609-
Args:
610-
rows: Input PyArrow table
611-
612-
Returns:
613-
PyArrow table with complex types converted to strings
614-
"""
615-
616-
if not pyarrow:
617-
return rows
618-
619-
def convert_complex_column_to_string(col: "pyarrow.Array") -> "pyarrow.Array":
620-
python_values = col.to_pylist()
621-
json_strings = [
622-
(None if val is None else json.dumps(val)) for val in python_values
623-
]
624-
return pyarrow.array(json_strings, type=pyarrow.string())
625-
626-
converted_columns = []
627-
for col in rows.columns:
628-
converted_col = col
629-
if (
630-
pyarrow.types.is_list(col.type)
631-
or pyarrow.types.is_large_list(col.type)
632-
or pyarrow.types.is_struct(col.type)
633-
or pyarrow.types.is_map(col.type)
634-
):
635-
converted_col = convert_complex_column_to_string(col)
636-
converted_columns.append(converted_col)
637-
638-
return pyarrow.Table.from_arrays(converted_columns, names=rows.column_names)
639-
640603
def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
641604
"""
642605
Fetch the next set of rows as an Arrow table.
@@ -662,9 +625,6 @@ def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
662625
results = self._convert_json_to_arrow(rows)
663626
self._next_row_index += results.num_rows
664627

665-
if not self.backend._use_arrow_native_complex_types:
666-
results = self._convert_complex_types_to_string(results)
667-
668628
return results
669629

670630
def fetchall_arrow(self) -> "pyarrow.Table":
@@ -679,9 +639,6 @@ def fetchall_arrow(self) -> "pyarrow.Table":
679639
results = self._convert_json_to_arrow(rows)
680640
self._next_row_index += results.num_rows
681641

682-
if not self.backend._use_arrow_native_complex_types:
683-
results = self._convert_complex_types_to_string(results)
684-
685642
return results
686643

687644
def fetchone(self) -> Optional[Row]:

0 commit comments

Comments
 (0)