0

I am trying to iterate through every row of the first column of the following output.

Assume table Employees has 3 columns: FirstName, MiddleName, LastName

table1=spark.sql("Select * from Employees")

enter image description here

2
  • what do you want to do with that iteration? Commented Mar 3, 2022 at 21:58
  • just print each row. so tom, bob, gary would be printed @pltc Commented Mar 3, 2022 at 22:00

1 Answer 1

1

If your table is small enough, then collect would be the best table1.select('FirstName').collect()

However, keep in mind that collect is not scalable, as it uses a single machine instead of distributing the workload to workers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.