I have two dataframes the first one has two columns , the second one has 5 fields , i want to compare the first dataframe with two special column from the second .If it exists i make an update else i insert the two column in the two special fields . i am new , i need some help to continue thanks
Here what i did
package Test
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions._
object TMP_STRUCTURE extends App {
System.setProperty("hadoop.home.dir", "C:\\hadoop");
System.setProperty("spark.sql.warehouse.dir", "file:///C:/spark-warehouse");
val sparkSession = SparkSession.builder.master("local").appName("spark session example").getOrCreate()
//connect to table TMP_STRUCTURE oracle
val spark = sparkSession.sqlContext
val df = spark.load("jdbc",
Map("url" -> "jdbc:oracle:thin:IPTECH/IPTECH@//localhost:1521/XE",
"dbtable" -> "IPTECH.TMP_STRUCTURE"))
df.printSchema()
val article_groups = spark.load("jdbc", Map(
"url" -> "jdbc:postgresql://localhost:5432/gemodb?user=postgres&password=maher",
"dbtable" -> "article_groups"))
article_groups.printSchema()
}
root
|-- CODE: string (nullable = false)
|-- LIBELLE: string (nullable = false)
root
|-- id: long (nullable = false)
|-- is_enabled: boolean (nullable = true)
|-- code: string (nullable = true)
|-- name: string (nullable = true)
|-- number: string (nullable = true)
i want to comapare code and libelle with id and name based on the column code and id
Any help thanks