无法在X行上广播表:X行

2024-10-04 07:30:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试运行广播连接,但出现以下错误: Caused by: org.apache.spark.SparkException: Cannot broadcast the table over 357913941 rows: 480202810 rows. 此处设置spark源代码中的最大行数:

代码如下:

right_df = right_df.withColumn("new_col", F.to_timestamp("date") + F.expr("INTERVAL 30 minutes")*F.col('period'))

join_condition = [right_df.col_0 == left_df.col_0, 
                  right_df.col_1 == left_df.col_1, 
                  right_df.col_2 == left_df.col_2,
                  right_df.col_3 == left_df.col_3,
                  right_df.time_point.between(left_df.interval_start, left_df.interval_end)]

df = left_df.join(F.broadcast(right_df), on=join_condition, how='left')

我的right_df数据帧只有1,7GB,小于限制8GB。 我已将spark.sql.autoBroadcastJoinThreshold设置为8GB:

value = 8*10**9
spark.conf.set("spark.sql.autoBroadcastJoinThreshold", f'{value}')

设置:Databricks运行时版本7.5(包括Apache Spark 3.0.1、Scala 2.12)


Tags: rightdfsqlvaluestep错误colcondition