title: Spark Dataframes UPSERT to Postgres Table
body: <p>I am using Apache Spark DataFrames to join two data sources and get the result as another DataFrame. I want to write the result to another Postgres table. I see this option :</p>
  
  <pre><code>myDataFrame.write.jdbc(url, table, connectionProperties)
  </code></pre>
  
  <p>But, what I want to do is UPSERT the dataframe into table based on the Primary Key of the Table. How is this to be done? I am using Spark 1.6.0.</p>