Когда я пытаюсь установить зависимость пакета "spark-sftp" в моей конфигурации Spark, я получаю ClassNotFoundException. Но это работает, когда я выполняю скрипт, используя:
spark-submit --packages com.springml: spark-sftp_2.11: 1.1.1 test.py
Ниже мой код. Может кто-нибудь сказать мне, как я могу выполнить мой скрипт pyspark
без передачи пакета в качестве аргумента для spark-submit?
import sys
import datetime
import pyspark
from pyspark.sql import *
from pyspark.sql import SparkSession, SQLContext, Row, HiveContext
from pyspark import SparkContext
#Create new config
conf = (pyspark.conf.SparkConf()
.set("spark.driver.maxResultSize", "16g")
.set("spark.driver.memory", "20g")
.set("spark.executor.memory", "20g")
.set("spark.executor.cores", "5")
.set("spark.shuffle.service.enabled", "true")
.set("spark.dynamicAllocation.enabled", "true")
.set("spark.dynamicAllocation.initialExecutors", "24")
.set("spark.dynamicAllocation.minExecutors", "6")
.set("spark.submit.deployMode", "client")
.set("spark.jars.packages", "com.springml:spark-sftp_2.11:1.1.1")
.set("spark.python.worker.memory", "4g")
.set("spark.default.parallelism", "960")
.set("spark.executor.memoryOverhead", "4g")
.setMaster("yarn-client"))
# Create new context
spark = SparkSession.builder.appName("AppName").config(conf=conf).enableHiveSupport().getOrCreate()
spark.sparkContext.setLogLevel("WARN")
df = spark.read.format("com.springml.spark.sftp").option("host", "HOST").option("username", "HOSTNAME").option("password", "pass").option("fileType", "csv").option("inferSchema", "true").load("/test/sample.csv")
Выход:
: java.lang.ClassNotFoundException: не удалось найти источник данных: com.springml.spark.sftp. Пожалуйста, найдите пакеты на http://spark.apache.org/third-party-projects.html
в org.apache.spark.sql.execution.datasources.DataSource $ .lookupDataSource (DataSource.scala: 635)
в org.apache.spark.sql.DataFrameReader.load (DataFrameReader.scala: 190)
в org.apache.spark.sql.DataFrameReader.load (DataFrameReader.scala: 174)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
в java.lang.reflect.Method.invoke (Method.java:498)
на py4j.reflection.MethodInvoker.invoke (MethodInvoker.java:244)
в py4j.reflection.ReflectionEngine.invoke (ReflectionEngine.java:357)
at py4j.Gateway.invoke (Gateway.java:282)
на py4j.commands.AbstractCommand.invokeMethod (AbstractCommand.java:132)
на py4j.commands.CallCommand.execute (CallCommand.java:79)
at py4j.GatewayConnection.run (GatewayConnection.java:238)
на java.lang.Thread.run (Thread.java:748)
Вызывается: java.lang.ClassNotFoundException: com.springml.spark.sftp.DefaultSource