Guest User

Untitled

a guest
Oct 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. for row in df3.rdd.collect():
  2. d=row.asDict()
  3. codice_te=d["ID_TIPO_EVENTO"]
  4. codice_de=d["ID_DETTAGLIO_EVENTO"]
  5. descr_te,descr_de=self.F_Anag(jsonI,"TIPO_EVENTO",codice_te,"DETTAGLIO_EVENTO",codice_de)
  6. descr_te=codice_te if descr_te is None else descr_te
  7. descr_de=codice_de if descr_de is None else descr_de
  8.  
  9. val selectCase = udf((tc: String, amt: String) =>
  10. if (Seq("a", "b").contains(tc)) "Y"
  11. else if (tc == "a" && amt.toInt <= 0) "N"
  12. else null
  13. )
  14.  
  15.  
  16. dataset1.withColumn("REASON", selectCase(col("tc"), col("amt")))
  17.  
  18. import spark.implicits._
  19.  
  20. when($"tc" isin ("a", "b"), "Y")
  21. .when($"tc" === "a" && $"amt" >= 0, "N")
Add Comment
Please, Sign In to add comment