Я постоянно сталкиваюсь с ошибками, связанными с драйвером: р>
Код: Выделить всё
• java.sql.SQLException: No suitable driver
• java.lang.ClassNotFoundException: com.amazon.redshift.jdbc42.Driver
Код: Выделить всё
1. Setup:
• Spark version: (e.g., Spark 3.3.1)
• Hadoop AWS packages: --packages org.apache.hadoop:hadoop-aws:3.3.1,com.amazonaws:aws-java-sdk-bundle:1.11.901
• Redshift JDBC driver: RedshiftJDBC42-2.1.0.30.jar downloaded from Amazon’s official site.
2. spark-submit command:
--conf spark.driver.bindAddress=127.0.0.1
--conf spark.driver.host =127.0.0.1
--driver-memory 4g
--packages org.apache.hadoop:hadoop-aws:3.3.1,com.amazonaws:aws-java-sdk-bundle:1.11.901
--jars /path/to/RedshiftJDBC42-2.1.0.30 .jar
--drive-class-path /path/to/RedshiftJDBC42-2.1.0.30.jar
my_script.py
Я попробовал добавить --driver-class-path, чтобы драйвер виден водителю. Файл JAR определенно существует по указанному пути.
Код: Выделить всё
3. In the Python Code:
(df.write
.format("jdbc")
.option ("url", jdbc_url)
.option("dbtable", "public.my_staging_table")
.option("user", os.environ["REDSHIFT_USER"])
.option("пароль", os.environ["REDSHIFT_PASSWORD"])
.option("driver", "com.amazon.redshift.jdbc42.Driver ")
.mode("append")
.save())
Код работает нормально до тех пор, пока .save(), после чего я получаю сообщение «Нет подходящего драйвера» или исключение ClassNotFoundException для класса драйвера Redshift.
Что я знаю:
Код: Выделить всё
• The Redshift JDBC driver class should be com.amazon.redshift.jdbc42.Driver.
• I’ve seen suggestions to use --driver-class-path plus --jars to ensure the driver is on both driver and executor classpaths.
• If I remove --driver-class-path, I sometimes get ClassNotFoundException. With it, I still get No suitable driver.
• My AWS credentials and S3 reading works fine (I can read JSON from S3). The problem occurs only at the JDBC write to Redshift step.
Код: Выделить всё
• Is there another configuration step needed to ensure Spark recognizes the Redshift driver?
• Do I need to specify any additional spark configs for the JDBC driver?
• Are there known compatibility issues with this Redshift driver version and Spark/Hadoop versions?
• Should I consider a different Redshift driver JAR or a different approach (like spark-redshift or redshift-jdbc42-no-awssdk JAR)?
Подробнее здесь: https://stackoverflow.com/questions/792 ... dexception