Getting error while loading parquet data into Postgres (using spark-postgres library) ClassNotFoundException: Failed to find data source: postgres. Please find packages at http://spark.apache.org/third-party-projects.html Caused by: ClassNotFoundException
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 04:10 AM
Hi Fellas - I'm trying to load parquet data (in GCS location) into Postgres DB (google cloud) . For bulk upload data into PG we are using (spark-postgres library)
Pre requisite- To use above library , I have uploaded jar in my cluster
1- https://mvnrepository.com/artifact/io.frama.parisni/spark-postgres/0.0.1
2- https://mvnrepository.com/artifact/org.postgresql/postgresql
%scala
val data = spark.read.format("postgres")
.option("url","jdbc:postgres://IP:PORT/DATABASE?user=USERNAME¤tSchema=SCHEMANAME")
.option("password","PASSWORD")
.option("query","select * from TABLENAME")
.option("partitions",4)
.option("numSplits",5)
.option("multiline",true)
.load
But it is giving error -
ClassNotFoundException: Failed to find data source: postgres. Please find packages at http://spark.apache.org/third-party-projects.html Caused by: ClassNotFoundException: postgres.DefaultSource
P.S- Since my data is huge I need to use bulk load operation since by jdbc connection and inserting via cursor batch is not optimal method .
Let me know if there are any other methods available for bulk insert .
Data size ~ 40 GB parquet
Regards,
- Labels:
-
Datasource
-
Gcs