Void S
Void S

Reputation: 802

PySpark - Getting each row of first column

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

Upvotes: 0

Views: 142

Answers (1)

pltc
pltc

Reputation: 6082

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.

Upvotes: 1

Related Questions