1

I'm using Spark 2.4.4, when I enter pyspark shell, I specify delta lake and jackson packages as below:

    pyspark --packages io.delta:delta-core_2.11:0.6.1,com.fasterxml.jackson.module:jackson-module-scala_2.11:2.6.7.1 --conf "spark.sql.extensions=io.delta.sql.DeltaSparkSessionExtension" --conf "spark.sql.catalog.spark_catalog=org.apache.spark.sql.delta.catalog.DeltaCatalog"

But then got below error:

data.write.format("delta").save("/tmp/delta-table") Traceback (most recent call last): File "", line 1, in File "/usr/hdp/current/spark2-client/python/pyspark/sql/readwriter.py", line 738, in save self.jwrite.save(path) File "/usr/hdp/current/spark2-client/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in call File "/usr/hdp/current/spark2-client/python/pyspark/sql/utils.py", line 63, in deco return f(*a, **kw) File "/usr/hdp/current/spark2-client/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value py4j.protocol.Py4JJavaError: An error occurred while calling o91.save. : java.lang.NoSuchMethodError: com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper.com$fasterxml$jackson$module$scala$experimental$ScalaObjectMapper$setter$com$fasterxml$jackson$module$scala$experimental$ScalaObjectMapper$$MAP$eq(Ljava/lang/Class;)V at com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper$class.$init$(ScalaObjectMapper.scala:331) at org.apache.spark.sql.delta.util.JsonUtils$$anon$1.(JsonUtils.scala:27) at org.apache.spark.sql.delta.util.JsonUtils$.(JsonUtils.scala:27) at org.apache.spark.sql.delta.util.JsonUtils$.(JsonUtils.scala) at org.apache.spark.sql.delta.DeltaOperations$Write$$anonfun$1.apply(DeltaOperations.scala:58) at org.apache.spark.sql.delta.DeltaOperations$Write$$anonfun$1.apply(DeltaOperations.scala:58) at scala.Option.map(Option.scala:146) at org.apache.spark.sql.delta.DeltaOperations$Write.(DeltaOperations.scala:58) at org.apache.spark.sql.delta.commands.WriteIntoDelta$$anonfun$run$1.apply(WriteIntoDelta.scala:66) at org.apache.spark.sql.delta.commands.WriteIntoDelta$$anonfun$run$1.apply(WriteIntoDelta.scala:64) at org.apache.spark.sql.delta.DeltaLog.withNewTransaction(DeltaLog.scala:188) at org.apache.spark.sql.delta.commands.WriteIntoDelta.run(WriteIntoDelta.scala:64) at org.apache.spark.sql.delta.sources.DeltaDataSource.createRelation(DeltaDataSource.scala:134) 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:676) at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:676) at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:78) at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:125) at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73) at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:676) at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:285) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:271) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:229) 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)

Alex Liu
  • 11
  • 2
  • why are you specifying `jackson-module-scala` explicitly? – Alex Ott Sep 30 '20 at 18:12
  • 1
    just tested with Spark 2.4.6 - works just fine. Check with what Scala version your Spark is compiled - do the `ls jars/*_2.1*` from spark folder, it should have `_2.11` on all jars. If not, then you need to use delta compiled for Scala 2.12 – Alex Ott Sep 30 '20 at 18:16
  • Hi Alex, yes, it do have jackson-module-scala 2.11 in jars folder. But if I don't specify jajckson-module-scala, the error is: https://raw.githubusercontent.com/liualexiang/images/master/pyspark%20error – Alex Liu Oct 04 '20 at 00:19
  • I would say that it could be some dependency conflict in HDP... I would try to create an uberjar of delta with its dependencies, and use it... – Alex Ott Oct 04 '20 at 16:52
  • How to specify spark version when build delta uber jar? https://github.com/delta-io/connectors#delta-uber-jar – Alex Liu Oct 05 '20 at 08:33
  • as I understand you need to checkout corresponding branch - 0.6 for Spark 2.4.x – Alex Ott Oct 05 '20 at 08:36
  • but seems there is only master branch currently: https://github.com/delta-io/connectors/branches/all – Alex Liu Oct 05 '20 at 08:42
  • just create a dummy pom.xml that includes dependency on delta + jackson, and build the uberjar – Alex Ott Oct 05 '20 at 08:56
  • @AlexOtt any update on this? Did you resolve the issue? – Murali krishna Jan 25 '21 at 12:22
  • @AlexLiu any updates on issue? did you resolve it? – Shalaj Apr 19 '21 at 11:34
  • If anyone is still facing such error, please have a look at: https://stackoverflow.com/a/69617788/8215996 – abhimanyu singh Oct 18 '21 at 14:27

0 Answers0