Reputation: 37
My Dataset< Row > (java spark) input is :
Heros | Powers | Rank |
---|---|---|
Superman | Invisible | 1 |
Batman | Strength | 2 |
SpiderMan | Strong | 3 |
By knowing the name of my heros, i would like to retrieve the rank. For exemple for Superman, i would like to have the return 1, not all the line but just the value. I don't know how to do by using a spark dataset. Thank for your help !
Upvotes: 0
Views: 633
Reputation: 32660
You can try:
int rank = dataset.filter("Heros ='Superman'").select(col("Rank")).first().getInt(0);
Upvotes: 1