code: def test_mixed_sql_and_udf(self):
      df = self.data
      w = self.unbounded_window
      ow = self.ordered_window
      max_udf = self.pandas_agg_max_udf
      min_udf = self.pandas_agg_min_udf
  
      result1 = df.withColumn(
          "v_diff", max_udf(df["v"]).over(w) - min_udf(df["v"]).over(w)
      )
      expected1 = df.withColumn(
          "v_diff", max(df["v"]).over(w) - min(df["v"]).over(w)
      )
  
      # Test mixing sql window function and window udf in the same expression
      result2 = df.withColumn(
          "v_diff", max_udf(df["v"]).over(w) - min(df["v"]).over(w)
      )
      expected2 = expected1
  
      # Test chaining sql aggregate function and udf
      result3 = (
          df.withColumn("max_v", max_udf(df["v"]).over(w))
          .withColumn("min_v", min(df["v"]).over(w))
          .withColumn("v_diff", col("max_v") - col("min_v"))
          .drop("max_v", "min_v")
      )
      expected3 = expected1
  
      # Test mixing sql window function and udf
      result4 = df.withColumn(
          "max_v", max_udf(df["v"]).over(w)
      ).withColumn("rank", rank().over(ow))
      expected4 = df.withColumn(
          "max_v", max(df["v"]).over(w)
      ).withColumn("rank", rank().over(ow))
  
      assert_frame_equal(expected1.toPandas(), result1.toPandas())
      assert_frame_equal(expected2.toPandas(), result2.toPandas())
      assert_frame_equal(expected3.toPandas(), result3.toPandas())
      assert_frame_equal(expected4.toPandas(), result4.toPandas())
  
imports: import unittest
  from typing import cast
  from pyspark.errors import AnalysisException, PythonException
  from pyspark.sql.functions import array, explode, col, lit, mean, min, max, rank, udf, pandas_udf, PandasUDFType
  from pyspark.sql.window import Window
  from pyspark.testing.sqlutils import ReusedSQLTestCase, have_pandas, have_pyarrow, pandas_requirement_message, pyarrow_requirement_message
  from pyspark.testing.utils import QuietTest, assertDataFrameEqual
label_desc: Use image node_id 24 for calling the WindowPandasUDFTestsMixin obj's underlying member method code with example usage: obj.test_mixed_sql_and_udf() without return types