Search code examples
javaapache-sparkapache-spark-sqlapache-spark-mllib

Spark Java - How do I iterate rows in dataframe Dataset<Row>, and add values of one column to an Arraylist


I have a Dataset<Row> containing 3 columns in Java. I want to iterate on its rows, then add the values of this column to an ArrayList. Could anyone help me?

Please take on consideration that I work in Java.

Thank you.


Solution

  • Thank you Ernest Kiwele.

    it worked in this way :

    List<Row> arrayList= new ArrayList<>();
    arrayList=dataset.collectAsList();