Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. {
  2. val finalResult = hiveContext.sql("""SELECT * from """ + temptableName + """)
  3.  
  4. if (finalResult.count() > 0) {
  5. finalResult.foreach { row =>
  6.  
  7. RealtimeUtil.loadStreamProperties("TestFlow.properties")
  8. val tag1 = row.getAs("new_val1").asInstanceOf[String]
  9. val tag2 = row.getAs("new_val2").asInstanceOf[String]
  10.  
  11.  
  12. val string = """This is a template string with some value
  13. "-Name":"TAG1", "#text":"****",
  14. "-Name":"TAG2", "#text":"****"
  15. """
  16.  
  17. val string2 = string
  18. .replace(""""-Name":"TAG1", "#text":"****"""", """"-Name":"TAG1", "#text":"""" + new_val1 +""")
  19. .replace(""""-Name":"TAG2", "#text":"****"""", """"-Name":"TAG2", "#text":"""" + new_val2 +""")
  20.  
  21. hiveContext.sql("""insert into table testdb.final_table values ("""" + string2 + ")"""
  22. \above statement failing with NPE
  23. val someDF = Seq((1, string2)).toDF("seq", "value").coalesce(1).select("value").write.format("text").mode("append").save("/tmp/output")
  24. \above statement failing with NPE
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement