如何根据条件添加新列(而不面临 JaninoRuntimeException 或 OutOfMemoryError)?

2024-05-17

尝试根据这样的条件创建具有多个附加列的 Spark 数据框

df
    .withColumn("name1", someCondition1)
    .withColumn("name2", someCondition2)
    .withColumn("name3", someCondition3)
    .withColumn("name4", someCondition4)
    .withColumn("name5", someCondition5)
    .withColumn("name6", someCondition6)
    .withColumn("name7", someCondition7)

如果超过 6 个,我会遇到以下异常.withColumn添加了条款

org.codehaus.janino.JaninoRuntimeException: Code of method "()V" of class "org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIterator" grows beyond 64 KB

这个问题也已在其他地方报告过,例如

  • Spark ML Pipeline 导致 java.lang.Exception:编译失败...代码...增长超过 64 KB https://stackoverflow.com/questions/39012073/spark-ml-pipeline-causes-java-lang-exception-failed-to-compile-code-gro
  • https://github.com/rstudio/sparklyr/issues/264 https://github.com/rstudio/sparklyr/issues/264

Spark 中有可以配置大小的属性吗?

edit

如果创建更多列,例如大约 20 我不再收到上述异常,而是在等待 5 分钟后收到以下错误:

java.lang.OutOfMemoryError: GC overhead limit exceeded

我想要执行的是拼写/纠错。一些简单的情况可以通过 UDF 中的映射和替换轻松处理。尽管如此,其他几起具有多重连锁条件的案件仍然存在。

我也会跟进那里:https://issues.apache.org/jira/browse/SPARK-18532 https://issues.apache.org/jira/browse/SPARK-18532

可以在这里找到最小的可重复示例https://gist.github.com/geoHeil/86e5401fc57351c70fd49047c88cea05 https://gist.github.com/geoHeil/86e5401fc57351c70fd49047c88cea05


此错误是由 WholeStageCodegen 和 JVM 问题引​​起的。

快速回答:不,您无法更改限制。请看this https://stackoverflow.com/questions/17422480/maximum-size-of-a-method-in-java-7-and-8问题,64KB是JVM中的最大方法大小。

我们必须等待 Spark 中的解决方法,目前系统参数中无法更改任何内容

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何根据条件添加新列(而不面临 JaninoRuntimeException 或 OutOfMemoryError)? 的相关文章

随机推荐