code: def create_filter_clauses(
      mapping: dict,
      information_schema_table: Table,
      uppercase_names: bool = False,
  ) -> ClauseElement:
      """
      Creates comprehensive filter clauses for all tables in one database.
  
      :param mapping: a nested dictionary of database, schema names and list of tables in each
      :param information_schema_table: `sqlalchemy.Table` instance used to construct clauses
          For most SQL dbs it contains `table_name` and `table_schema` columns,
          therefore it is expected the table has them defined.
      :param uppercase_names: if True use schema and table names uppercase
      """
      table_schema_column_name = information_schema_table.columns[
          ColumnIndex.SCHEMA
      ].name
      table_name_column_name = information_schema_table.columns[
          ColumnIndex.TABLE_NAME
      ].name
      try:
          table_database_column_name = information_schema_table.columns[
              ColumnIndex.DATABASE
          ].name
      except IndexError:
          table_database_column_name = ""
  
      filter_clauses = []
      for db, schema_mapping in mapping.items():
          schema_level_clauses = []
          for schema, tables in schema_mapping.items():
              filter_clause = information_schema_table.c[
                  table_name_column_name
              ].in_(
                  name.upper() if uppercase_names else name
                  for name in tables
              )
              if schema:
                  schema = schema.upper() if uppercase_names else schema
                  filter_clause = and_(
                      information_schema_table.c[
                          table_schema_column_name
                      ]
                      == schema,
                      filter_clause,
                  )
              schema_level_clauses.append(filter_clause)
          if db and table_database_column_name:
              db = db.upper() if uppercase_names else db
              filter_clause = and_(
                  information_schema_table.c[table_database_column_name]
                  == db,
                  or_(*schema_level_clauses),
              )
              filter_clauses.append(filter_clause)
          else:
              filter_clauses.extend(schema_level_clauses)
      return or_(*filter_clauses)
  
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 4 for calling a global function with example usage: create_filter_clauses(mapping, information_schema_table, uppercase_names) and returns: or_