java.lang.NoClassDefFoundError:将Delta-Lake写入s3存储时,org / apache / spark / sql / catalyst / plans / logical / AnalysisHelper

时间:2019-06-03 14:57:22

标签: apache-spark amazon-s3 delta-lake

我试图将s3中的一些腌制文件转换为三角洲湖泊。我这样做的方法是使用boto加载数据并转换为spark数据框,然后使用data.write.format('delta')。save(s3_path)

但是当我尝试将此数据保存到s3中时。它引起了我这个错误。我在Google上搜索了很长时间,但三角洲湖却是一个新事物。没有什么讨论。

由于错误显示java.lang.NoClassDefFoundError:org / apache / spark / sql / catalyst / plans / logical / AnalysisHelper,所以我检查了spark github的源代码。 AnalysisHelper的实际路径是spark / sql / catalyst / src / main / scala / org / apache / spark / sql / catalyst / plans / logical /。我不确定这是否是错误的根源。


def test_pyspark_fun():

    spark = SparkSession.builder.appName('abc').getOrCreate()
    data = spark.range(0, 5)
    spark.read.format("delta")
    print("writing...")
    data.write.format("delta").save("s3a://bucket/folder/delta_lake_test_folder")
    print("writing done...")

我使用命令

运行
spark-submit --packages io.delta:delta-core_2.11:0.1.0,org.apache.hadoop:hadoop-aws:2.7.3 pyspark_script.py

这是错误消息

py4j.protocol.Py4JJavaError: An error occurred while calling o40.save.
: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/apache/spark/sql/catalyst/plans/logical/AnalysisHelper$
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2261)
    at com.google.common.cache.LocalCache.get(LocalCache.java:4000)
    at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4789)
    at org.apache.spark.sql.delta.DeltaLog$.apply(DeltaLog.scala:721)
    at org.apache.spark.sql.delta.DeltaLog$.forTable(DeltaLog.scala:653)
    at org.apache.spark.sql.delta.sources.DeltaDataSource.createRelation(DeltaDataSource.scala:139)
    at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:45)
    at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
    at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
    at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:86)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:127)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:155)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
    at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:152)
    at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:127)
    at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:80)
    at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:80)
    at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:656)
    at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:656)
    at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:77)
    at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:656)
    at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:273)
    at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:267)
    at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:225)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:282)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/apache/spark/sql/catalyst/plans/logical/AnalysisHelper$
    at org.apache.spark.sql.delta.DeltaLog$$anon$3$$anonfun$call$1.apply(DeltaLog.scala:724)
    at org.apache.spark.sql.delta.DeltaLog$$anon$3$$anonfun$call$1.apply(DeltaLog.scala:724)
    at com.databricks.spark.util.DatabricksLogging$class.recordOperation(DatabricksLogging.scala:75)
    at org.apache.spark.sql.delta.DeltaLog$.recordOperation(DeltaLog.scala:626)
    at org.apache.spark.sql.delta.metering.DeltaLogging$class.recordDeltaOperation(DeltaLogging.scala:105)
    at org.apache.spark.sql.delta.DeltaLog$.recordDeltaOperation(DeltaLog.scala:626)
    at org.apache.spark.sql.delta.DeltaLog$$anon$3.call(DeltaLog.scala:723)
    at org.apache.spark.sql.delta.DeltaLog$$anon$3.call(DeltaLog.scala:721)
    at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4792)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3599)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2379)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2342)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2257)
    ... 35 more
Caused by: java.lang.ClassNotFoundException: org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper$
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 48 more

希望有人可以帮助我。或其他任何人都知道将delta-lake文件夹写入s3的任何其他方法。预先感谢!

更新

现在的三角洲湖泊支持直接连接s3。选中here

1 个答案:

答案 0 :(得分:3)

您的Spark版本是什么? org / apache / spark / sql / catalyst / plans / logical / AnalysisHelper在2.4.0中发布。如果使用的是较旧的版本,则会出现此问题。

在2.4.0中 https://github.com/apache/spark/tree/v2.4.0/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical

在2.3.3中 https://github.com/apache/spark/tree/v2.3.3/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical

请注意,Delta Lake currently requires Apache Spark 2.4.2