首页 > 解决方案 > Pyspark:长过滤器链使驱动程序挂起

问题描述

假设我们有一个要构建过滤器链的谓词列表。当谓词列表超过 ~20 时,驱动程序就会挂起,并且作业永远不会出现在 spark ui 中。

例如:

df = spark.table('test.test')

for predicate in predicates_list:
    positive_case = df.filter(predicate)
    negative_case = df.filter(~predicate)
    #some changes are made to negative and positive case
    df = positive_case.union(negative_case)

df.show()

我能想到的唯一选择是将所有这些都写在一个 python 函数中,然后跳入 rdd 领域。然而,对于一个看似微不足道的问题,这似乎是一个非常老套的解决方案。

标签: pythonapache-sparkpyspark

解决方案


推荐阅读