code: def test_pandas_udf_arrow_overflow(self):
      import pandas as pd
  
      df = self.spark.range(0, 1)
  
      @pandas_udf(returnType="byte")
      def udf(column):
          return pd.Series([128] * len(column))
  
      # When enabling safe type check, Arrow 0.11.0+ disallows overflow cast.
      with self.sql_conf(
          {"spark.sql.execution.pandas.convertToArrowArraySafely": True}
      ):
          with self.assertRaisesRegex(
              Exception,
              "Exception thrown when converting pandas.Series",
          ):
              df.withColumn("udf", udf("id")).collect()
  
      # Disabling safe type check, let Arrow do the cast anyway.
      with self.sql_conf(
          {
              "spark.sql.execution.pandas.convertToArrowArraySafely": False
          }
      ):
          df.withColumn("udf", udf("id")).collect()
  
imports: import unittest
  import datetime
  from typing import cast
  from pyspark.sql.functions import udf, pandas_udf, PandasUDFType, assert_true, lit
  from pyspark.sql.types import DoubleType, StructType, StructField, LongType, DayTimeIntervalType
  from pyspark.errors import ParseException, PythonException, PySparkTypeError
  from pyspark.rdd import PythonEvalType
  from pyspark.testing.sqlutils import ReusedSQLTestCase, have_pandas, have_pyarrow, pandas_requirement_message, pyarrow_requirement_message
  from pyspark.testing.utils import QuietTest
label_desc: Use image node_id 11 for calling the PandasUDFTestsMixin obj's underlying member method code with example usage: obj.test_pandas_udf_arrow_overflow() and returns: pd