Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. Dataset<Row> words = df
  2. .selectExpr("CAST (value AS STRING)")
  3. .as(Encoders.STRING())
  4. .withColumn("id", split(col("value"), ",").getItem(0))
  5. .withColumn("country", split(col("value"), ",").getItem(1))
  6. .withColumn("timestamp", split(col("value"), ",").getItem(2));
  7.  
  8.  
  9. +----+---------+----------+
  10. |id |country |timestamp |
  11. +----+---------+----------+
  12. |2922|de |1231231232|
  13. |4195|de |1231232424|
  14. |6796|fr |1232412323|
  15. +----+---------+----------+
  16.  
  17. Dataset<String> words.map(row -> {
  18. //do something with every entry of each row e.g.
  19. Person person = new Person(id, country, timestamp);
  20. String name = person.getName();
  21. return name;
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement