code: def duckdb_relation_to_schema(
      rel: duckdb.DuckDBPyRelation,
  ) -> pa.Schema:
      schema_fields = {}
      for col, type_name in zip(rel.columns, rel.dtypes):
          try:
              type_ = duckdb_type_name_to_pyarrow_type(type_name)
              schema_fields[col] = type_
          except ValueError:
              # Skip columns with unrecognized types
              pass
      return pa.schema(schema_fields)
  
imports: import re
  import warnings
  from .None import SqlConnection, CsvReadOptions
  from typing import Dict, Optional
  from distutils.version import LooseVersion
  import duckdb
  import pyarrow
  import pyarrow.feather
  import pandas
  import logging
  import uuid
label_desc: Use image node_id 2 for calling a global function with example usage: duckdb_relation_to_schema(rel) and returns: pa