code: def _cursor_to_block(cursor) -> Block:
      import pyarrow as pa
  
      rows = cursor.fetchall()
      # Each `column_description` is a 7-element sequence. The first element is the column
      # name. To learn more, read https://peps.python.org/pep-0249/#description.
      columns = [
          column_description[0]
          for column_description in cursor.description
      ]
      pydict = {
          column: [row[i] for row in rows]
          for i, column in enumerate(columns)
      }
      return pa.Table.from_pydict(pydict)
  
file_path: ray/python/ray/data/datasource/sql_datasource.py
imports: import math
  from contextlib import contextmanager
  from typing import Any, Callable, Iterable, Iterator, List, Optional
  from ray.data.block import Block, BlockAccessor, BlockMetadata
  from ray.data.datasource.datasource import Datasource, ReadTask
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 1 for calling a global function with example usage: _cursor_to_block(cursor) and returns: pa