Skip to content

Commit d92670d

Browse files
committed
Make use of compagnion object constructor
1 parent bfd5108 commit d92670d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ Usage
3838
// the connection looks into /home/$USER/.pgpass for a password
3939
val url = "jdbc:postgresql://somehost:someport/somedb?user=someuser&currentSchema=someschema"
4040
41-
val pg = new PGUtil(sparkSession, url, "spark-postgres-tmp" ) // specify a temporary folder in hdfs or locally
41+
val pg = PGUtil(sparkSession, url, "spark-postgres-tmp" ) // specify a temporary folder in hdfs or locally
4242
val df = pg
4343
.tableDrop("person_tmp") // drop table if exists
4444
.tableCopy("person","person_tmp") // duplicate the table without data
4545
.inputBulk(query="select * from person", numPartitions=4, partitionColumn="person_id") // get a df from the table
4646
47-
pg.outputBulk("person_tmp", df) // load the new table with the df
47+
pg.outputBulk("person_tmp", df, numPartitions=4) // load the new table with the df with 4 thread
4848
.tableDrop("person_tmp") // drop the temparary table
4949
.purgeTmp() // purge the temporary folder
5050

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>fr.aphp.wind.spark</groupId>
44
<artifactId>spark-postgres</artifactId>
5-
<version>2.1.1-SNAPSHOT</version>
5+
<version>2.2.0-SNAPSHOT</version>
66
<packaging>jar</packaging>
77
<url>https://github.com/EDS-APHP/spark-postgres</url>
88
<name>spark-postgres</name>

src/main/scala/PGUtil.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class PGUtil(spark:SparkSession, url: String, tmpPath:String) {
107107

108108
object PGUtil extends java.io.Serializable {
109109

110-
def apply(spark: SparkSession, url: String, tmpPath:String):PGUtil = new PGUtil(spark, url, tmpPath + randomUUID.toString)
110+
def apply(spark: SparkSession, url: String, tmpPath:String):PGUtil = new PGUtil(spark, url, tmpPath + randomUUID.toString).setPassword("")
111111

112112
private def dbPassword(hostname:String, port:String, database:String, username:String ):String = {
113113
// Usage: val thatPassWord = dbPassword(hostname,port,database,username)

0 commit comments

Comments
 (0)