Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. {"json_data":"{"table":"TEST.FUBAR","op_type":"I","op_ts":"2019-03-14 15:33:50.031848","current_ts":"2019-03-14T15:33:57.479002","pos":"1111","after":{"COL1":949494949494949494,"COL2":99,"COL3":2,"COL4":" 99999","COL5":9999999,"COL6":90,"COL7":42478,"COL8":"I","COL9":null,"COL10":"2019-03-14 15:33:49","COL11":null,"COL12":null,"COL13":null,"COL14":"x222263 ","COL15":"2019-03-14 15:33:49","COL16":"x222263 ","COL17":"2019-03-14 15:33:49","COL18":"2020-09-10 00:00:00","COL19":"A","COL20":"A","COL21":0,"COL22":null,"COL23":"2019-03-14 15:33:47","COL24":2,"COL25":2,"COL26":"R","COL27":"2019-03-14 15:33:49","COL28":" ","COL29":"PBU67H ","COL30":" 20000","COL31":2,"COL32":null}}"}
  2.  
  3. df = sqlContext.read.json("test_data.json")
  4.  
  5. {"json_data":"{"table":"TEST.FUBAR","op_type":"I","op_ts":"2019-03-14 15:33:50.031848","current_ts":"2019-03-14T15:33:57.479002","pos":"1111","after":{"COL1":949494949494949494,"COL2":99,"COL3":2,"COL4":" 99999","COL5":9999999,"COL6":90,"COL7":42478,"COL8":"I","COL9":null,"COL10":"2019-03-14 15:33:49","COL11":null,"COL12":null,"COL13":null,"COL14":"x222263 ","COL15":"2019-03-14 15:33:49","COL16":"x222263 ","COL17":"2019-03-14 15:33:49","COL18":"2020-09-10 00:00:00","COL19":"A","COL20":"A","COL21":0,"COL22":null,"COL23":"2019-03-14 15:33:47","COL24":2,"COL25":2,"COL26":"R","COL27":"2019-03-14 15:33:49","COL28":" ","COL29":"PBU67H ","COL30":" 20000","COL31":2,"COL32":null}}"}
  6.  
  7. {"json_data":{"table":"TEST.FUBAR","op_type":"I","op_ts":"2019-03-14 15:33:50.031848","current_ts":"2019-03-14T15:33:57.479002","pos":"1111","after":{"COL1":949494949494949494,"COL2":99,"COL3":2,"COL4":" 99999","COL5":9999999,"COL6":90,"COL7":42478,"COL8":"I","COL9":null,"COL10":"2019-03-14 15:33:49","COL11":null,"COL12":null,"COL13":null,"COL14":"x222263 ","COL15":"2019-03-14 15:33:49","COL16":"x222263 ","COL17":"2019-03-14 15:33:49","COL18":"2020-09-10 00:00:00","COL19":"A","COL20":"A","COL21":0,"COL22":null,"COL23":"2019-03-14 15:33:47","COL24":2,"COL25":2,"COL26":"R","COL27":"2019-03-14 15:33:49","COL28":" ","COL29":"PBU67H ","COL30":" 20000","COL31":2,"COL32":null}}}
  8.  
  9. Welcome to
  10. ____ __
  11. / __/__ ___ _____/ /__
  12. _ / _ / _ `/ __/ '_/
  13. /__ / .__/_,_/_/ /_/_ version 1.6.0
  14. /_/
  15.  
  16. Using Python version 2.7.13 (default, Dec 20 2016 23:09:15)
  17. SparkContext available as sc, HiveContext available as sqlContext.
  18. >>> filePath = "/user/no_quote_json.json"
  19. >>> df = sqlContext.read.json(filePath)
  20. >>> df.printSchema()
  21. root
  22. |-- json_data: struct (nullable = true)
  23. | |-- after: struct (nullable = true)
  24. | | |-- COL1: long (nullable = true)
  25. | | |-- COL10: string (nullable = true)
  26. | | |-- COL11: string (nullable = true)
  27. | | |-- COL12: string (nullable = true)
  28. | | |-- COL13: string (nullable = true)
  29. | | |-- COL14: string (nullable = true)
  30. | | |-- COL15: string (nullable = true)
  31. | | |-- COL16: string (nullable = true)
  32. | | |-- COL17: string (nullable = true)
  33. | | |-- COL18: string (nullable = true)
  34. | | |-- COL19: string (nullable = true)
  35. | | |-- COL2: long (nullable = true)
  36. | | |-- COL20: string (nullable = true)
  37. | | |-- COL21: long (nullable = true)
  38. | | |-- COL22: string (nullable = true)
  39. | | |-- COL23: string (nullable = true)
  40. | | |-- COL24: long (nullable = true)
  41. | | |-- COL25: long (nullable = true)
  42. | | |-- COL26: string (nullable = true)
  43. | | |-- COL27: string (nullable = true)
  44. | | |-- COL28: string (nullable = true)
  45. | | |-- COL29: string (nullable = true)
  46. | | |-- COL3: long (nullable = true)
  47. | | |-- COL30: string (nullable = true)
  48. | | |-- COL31: long (nullable = true)
  49. | | |-- COL32: string (nullable = true)
  50. | | |-- COL4: string (nullable = true)
  51. | | |-- COL5: long (nullable = true)
  52. | | |-- COL6: long (nullable = true)
  53. | | |-- COL7: long (nullable = true)
  54. | | |-- COL8: string (nullable = true)
  55. | | |-- COL9: string (nullable = true)
  56. | |-- current_ts: string (nullable = true)
  57. | |-- op_ts: string (nullable = true)
  58. | |-- op_type: string (nullable = true)
  59. | |-- pos: string (nullable = true)
  60. | |-- table: string (nullable = true)
  61.  
  62. >>> df.select("json_data.after.col29").show()
  63. +---------+
  64. | col29|
  65. +---------+
  66. |PBU67H |
  67. +---------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement