1
Я использую pyspark и загружаю DataFrame. Когда я пытаюсь сохранить его как файл CSV, я получаю ошибку ниже. Я инициализировать искру, как это:Spark save df as csv throws error
./pyspark --master local[4] --executor-memory 14g --driver-memory 14g --conf spark.local.dir=/mnt/bigdisk/spark_tmp --packages com.databricks:spark-csv_2.11:1.4.0
Ошибка:
df.write.save("/mnt/disk/df.csv", 'com.databricks.spark.csv', header = 'true', codec = None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/spark/python/pyspark/sql/readwriter.py", line 397, in save
self._jwrite.save(path)
File "/home/ubuntu/spark/python/lib/py4j-0.9- src.zip/py4j/java_gateway.py", line 813, in __call__
File "/home/ubuntu/spark/python/pyspark/sql/utils.py", line 45, in deco
return f(*a, **kw)
File "/home/ubuntu/spark/python/lib/py4j-0.9-src.zip/py4j/protocol.py", line 308, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o232.save.
: java.lang.NoClassDefFoundError: Could not initialize class com.databricks.spark.csv.util.CompressionCodecs$
at com.databricks.spark.csv.DefaultSource.createRelation(DefaultSource.scala:189)
at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:222)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:148)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:381)
at py4j.Gateway.invoke(Gateway.java:259)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:209)
at java.lang.Thread.run(Thread.java:745)
Вы скомпилировали Spark с помощью Scala 2.11? – zero323
попробуйте с com.databricks: spark-csv_2.11: 1.3.0 –
какую версию Spark вы используете? – RudyVerboven