0
 df_eximo_r_01.show()

+-----------+----------+---------+
|ID_DOSSIER1|ID_ENTITE1|DT_DEBUT1|
+-----------+----------+---------+
|       NULL|      NULL|     NULL|
+-----------+----------+---------+

When I execute this simple instruction it works:

df_eximo_r_01.foreach(x => for(i <- 0 to 2){if(x(i) == ("NULL")) println("Bonjour") })
//Bonjour
//Bonjour
//Bonjour

But when I try to increment a sequence using the same condition it doesn't add any lines to df_rejet:

df_eximo_r_01.foreach(x => for(i <- 0 to 2){
    if(x(i) == ("NULL")) 
     df_rejet = df_rejet :+(Rejet_Format("DWG_OF_EXIMO","INSERT",DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss").format(LocalDateTime.now),"R01","ID_DOSSIER","ID_ENTITE")) 
})
Bartosz Konieczny
  • 1,985
  • 12
  • 27
  • 3
    you cannot add data to a dataframe within a `foreach` applied to a dataframe. In fact I'm astonished that you don't get a nullpointer, I expected the dataframe to be null.... In executor side code, you are not expected to use rdd, dataframes, datasets etc – Raphael Roth Aug 27 '19 at 18:19
  • You've already asked the same question [here](https://stackoverflow.com/questions/57671655/insert-sequence-into-dataframe-returning-nullpointerexception), where somebody pointed to an answer in the comments. – user31601 Aug 28 '19 at 08:32
  • Possible duplicate of [NullPointerException in Scala Spark, appears to be caused be collection type?](https://stackoverflow.com/questions/23793117/nullpointerexception-in-scala-spark-appears-to-be-caused-be-collection-type) – user31601 Aug 28 '19 at 08:35

0 Answers0