February 2017
Intermediate to advanced
274 pages
5h 58m
English
Let's run the same queries, except this time, we will do so using SQL queries against the same DataFrame. Recall that this DataFrame is accessible because we executed the .createOrReplaceTempView method for swimmers.
The following is the code snippet to get the number of rows within your DataFrame using SQL:
spark.sql("select count(1) from swimmers").show()The output is as follows:

To run a filter statement using SQL, you can use the where clause, as noted in the following code snippet:
# Get the id, age where age = 22 in SQL spark.sql("select id, age from swimmers where ...Read now
Unlock full access