original_docstring: Parse schema error dicts to produce data for error message.
docstring: Parse schema error dicts to produce data for error message.
docstring_tokens: Parse schema error dicts to produce data for error message .
code: def _parse_schema_errors(schema_errors: List[Dict[str, Any]]):
          """Parse schema error dicts to produce data for error message."""
          error_counts = defaultdict(int)  # type: ignore
          check_failure_cases = []
  
          column_order = [
              "schema_context",
              "column",
              "check",
              "check_number",
              "failure_case",
              "index",
          ]
  
          for schema_error_dict in schema_errors:
              reason_code = schema_error_dict["reason_code"]
              err = schema_error_dict["error"]
  
              error_counts[reason_code] += 1
              check_identifier = (
                  None
                  if err.check is None
                  else err.check
                  if isinstance(err.check, str)
                  else err.check.error
                  if err.check.error is not None
                  else err.check.name
                  if err.check.name is not None
                  else str(err.check)
              )
  
              if err.failure_cases is not None:
                  if "column" in err.failure_cases:
                      column = err.failure_cases["column"]
                  else:
                      column = (
                          err.schema.name
                          if reason_code == "schema_component_check"
                          else None
                      )
  
                  failure_cases = err.failure_cases.assign(
                      schema_context=err.schema.__class__.__name__,
                      check=check_identifier,
                      check_number=err.check_index,
                      column=column,
                  )
                  check_failure_cases.append(failure_cases[column_order])
  
          failure_cases = (
              pd.concat(check_failure_cases)
              .reset_index(drop=True)
              .sort_values("schema_context", ascending=False)
          )
          return error_counts, failure_cases
code_tokens: def _parse_schema_errors ( schema_errors : List [ Dict [ str , Any ] ] ) : error_counts = defaultdict ( int ) check_failure_cases = [ ] column_order = [ "schema_context" , "column" , "check" , "check_number" , "failure_case" , "index" , ] for schema_error_dict in schema_errors : reason_code = schema_error_dict [ "reason_code" ] err = schema_error_dict [ "error" ] error_counts [ reason_code ] += 1 check_identifier = ( None if err . check is None else err . check if isinstance ( err . check , str ) else err . check . error if err . check . error is not None else err . check . name if err . check . name is not None else str ( err . check ) ) if err . failure_cases is not None : if "column" in err . failure_cases : column = err . failure_cases [ "column" ] else : column = ( err . schema . name if reason_code == "schema_component_check" else None ) failure_cases = err . failure_cases . assign ( schema_context = err . schema . __class__ . __name__ , check = check_identifier , check_number = err . check_index , column = column , ) check_failure_cases . append ( failure_cases [ column_order ] ) failure_cases = ( pd . concat ( check_failure_cases ) . reset_index ( drop = True ) . sort_values ( "schema_context" , ascending = False ) ) return error_counts , failure_cases
short_docstring: Parse schema error dicts to produce data for error message.
short_docstring_tokens: Parse schema error dicts to produce data for error message .
comment: """Parse schema error dicts to produce data for error message."""$SEP$# type: ignore