code: def validate_schema(
      df: DataFrame,
      required_schema: StructType,
      ignore_nullable: bool = False,
  ) -> None:
      """Function that validate if a given DataFrame has a given StructType as its schema.
  
      :param df: DataFrame to validate
      :type df: DataFrame
      :param required_schema: StructType required for the DataFrame
      :type required_schema: StructType
      :param ignore_nullable: (Optional) A flag for if nullable fields should be
      ignored during validation
      :type ignore_nullable: bool, optional
  
      :raises DataFrameMissingStructFieldError: if any StructFields from the required
      schema are not included in the DataFrame schema
      """
      _all_struct_fields = copy.deepcopy(df.schema)
      _required_schema = copy.deepcopy(required_schema)
  
      if ignore_nullable:
          for x in _all_struct_fields:
              x.nullable = None
  
          for x in _required_schema:
              x.nullable = None
  
      missing_struct_fields = [
          x for x in _required_schema if x not in _all_struct_fields
      ]
      error_message = f"The {missing_struct_fields} StructFields are not included in the DataFrame with the following StructFields {_all_struct_fields}"
  
      if missing_struct_fields:
          raise DataFrameMissingStructFieldError(error_message)
  
file_path: quinn/quinn/dataframe_validator.py
imports: from __future__ import annotations
  import copy
  from typing import TYPE_CHECKING
label_desc: Use image node_id 2 for calling a global function with example usage: validate_schema(df, required_schema, ignore_nullable) without return types