code: def parse_query_result(cursor) -> list[TableSchema]:
      """Fetch results from DB-API 2.0 cursor and creates list of table schemas.
  
      For each row it creates :class:`TableSchema`.
      """
      schemas: dict = {}
      columns: dict = defaultdict(list)
      for row in cursor.fetchall():
          table_schema_name: str = row[ColumnIndex.SCHEMA]
          table_name: str = row[ColumnIndex.TABLE_NAME]
          table_column: SchemaField = SchemaField(
              name=row[ColumnIndex.COLUMN_NAME],
              type=row[ColumnIndex.UDT_NAME],
              description=None,
          )
          ordinal_position = row[ColumnIndex.ORDINAL_POSITION]
          try:
              table_database = row[ColumnIndex.DATABASE]
          except IndexError:
              table_database = None
  
          # Attempt to get table schema
          table_key = ".".join(
              filter(
                  None, [table_database, table_schema_name, table_name]
              )
          )
  
          schemas[table_key] = TableSchema(
              table=table_name,
              schema=table_schema_name,
              database=table_database,
              fields=[],
          )
          columns[table_key].append((ordinal_position, table_column))
  
      for schema in schemas.values():
          table_key = ".".join(
              filter(
                  None, [schema.database, schema.schema, schema.table]
              )
          )
          schema.fields = [x for _, x in sorted(columns[table_key])]
  
      return list(schemas.values())
  
file_path: airflow/airflow/providers/openlineage/utils/sql.py
imports: from __future__ import annotations
  from collections import defaultdict
  from contextlib import closing
  from enum import IntEnum
  from typing import TYPE_CHECKING, Dict, List, Optional
  from attrs import define
  from openlineage.client.facet import SchemaDatasetFacet, SchemaField
  from openlineage.client.run import Dataset
  from sqlalchemy import Column, MetaData, Table, and_, or_, union_all
label_desc: Use image node_id 2 for calling a global function with example usage: parse_query_result(cursor) and returns: list