Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dataset<Row> words = df
- .selectExpr("CAST (value AS STRING)")
- .as(Encoders.STRING())
- .withColumn("id", split(col("value"), ",").getItem(0))
- .withColumn("country", split(col("value"), ",").getItem(1))
- .withColumn("timestamp", split(col("value"), ",").getItem(2));
- +----+---------+----------+
- |id |country |timestamp |
- +----+---------+----------+
- |2922|de |1231231232|
- |4195|de |1231232424|
- |6796|fr |1232412323|
- +----+---------+----------+
- Dataset<String> words.map(row -> {
- //do something with every entry of each row e.g.
- Person person = new Person(id, country, timestamp);
- String name = person.getName();
- return name;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement