def make_request(self) -> list:
spark: SparkSession = SparkSession.builder.remote("sc://localhost:15002").appName("SimpleApp").getOrCreate()
request = self.generate_query() # a select id from iceberg_catalog where some_filters
result = spark.sql(request) # type of <class 'pyspark.sql.connect.dataframe.DataFrame'>
result.show() # This works fine and shows the expected result (1 row of one string)
return result.collect() # This line causes a crash
show() 方法工作正常并显示预期的行。但是,程序在 result.collect() 处崩溃,并且我收到以下错误:
(org.apache.spark.SparkException) Job aborted due to stage failure: Task 0 in stage 43.0 failed 4 times, most recent failure: Lost task 0.3 in stage 43.0 (TID 85) (10.233.117.232 executor 0): java.lang.ClassCastException: cannot assign instance of java.lang.invoke.SerializedLambda to field org.apache.spark.rdd.MapPartitionsRDD.f of type scala.Function3 in instance of org.apache.spark.rdd.MapPartitionsRDD
据我了解,这可能与 Spark Connect 不支持的 RDD 操作有关(根据 Spark Connect 概述)。但是,DataFrame API 也有一个 Collect() 方法,Spark Connect 应该支持该方法。我尝试过其他方法,例如
take
或
count
,但似乎也不起作用,出现类似的错误。我不确定这里出了什么问题,因为我刚刚开始使用 Spark。这可能是我如何使用 Spark Connect 的问题,还是与collect() 方法有关的特定问题,或者 Spark Connect 设置错误的问题?任何见解或建议将不胜感激。
看起来 Apache 已经知道该问题,票号为:SPARK-46032