Skip to content

Use SparkSQL to determine key metrics of the data. Use Spark to create temporary views, partition the data, cache and uncache a temporary table, and verify that the table has been uncached.

Notifications You must be signed in to change notification settings

SteveTuttle/home-sales-sparkSQL-metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

home-sales-sparkSQL-metrics

UNC_data_bootcamp_module_22

Challenge Description

Background

In this challenge, you'll use your knowledge of SparkSQL to determine key metrics about home sales data. Then you'll use Spark to create temporary views, partition the data, cache and uncache a temporary table, and verify that the table has been uncached.

from the UNC Bootcamp description for this challenge

Deliverables

To accomplish this challenge I must complete following the instructions in a Google Colab Jupyter notebook:

  1. First I will rename the Home_Sales_starter_code.ipynb file as Home_Sales_SDT.ipynb.
  2. Import the necessary PySpark SQL functions for this assignment.
  3. Read the home_sales_revised.csv data in the starter code into a Spark DataFrame.
  4. Create a temporary table called home_sales.
  5. I will then answer the following questions using SparkSQL, saving each result as subQuery:
  • What is the average price for a four-bedroom house sold for each year? Round off your answer to two decimal places.
  • What is the average price of a home for each year it was built that has three bedrooms and three bathrooms? Round off your answer to two decimal places.
  • What is the average price of a home for each year that has three bedrooms, three bathrooms, two floors, and is greater than or equal to 2,000 square feet? Round off your answer to two decimal places.
  • What is the "view" rating for homes costing more than or equal to $350,000? Determine the run time for this query, and round off your answer to two decimal places.
  1. Cache your temporary table home_sales.
  2. Check if your temporary table is cached.
  3. Using the cached data, run the query that filters out the view ratings with an average price of greater than or equal to $350,000. Determine the runtime and compare it to uncached runtime.
  4. Partition by the "date_built" field on the formatted parquet home sales data.
  5. Create a temporary table for the parquet data.
  6. Run the query that filters out the view ratings with an average price of greater than or equal to $350,000. Determine the runtime and compare it to uncached runtime.
  7. Uncache the home_sales temporary table.
  8. Verify that the home_sales temporary table is uncached using PySpark.
  9. Download your Home_Sales.ipynb file and upload it into your "Home_Sales" GitHub repository.

Special Note: There was a vast improvement in runtime after the temporary table was cached, however the improvement after the partition was only very slight.

Resources

Bootcamp References

Module 22 Instructions

Module 22 class activities

starter_code

  • Home_Sales_starter_code.ipynb
  • Home_Sales_starter_code_colab.ipynb

Special Thanks:

  • Jamie Miller
  • Mounika Mamindla
  • Lisa Shemanciik

External References

About

Use SparkSQL to determine key metrics of the data. Use Spark to create temporary views, partition the data, cache and uncache a temporary table, and verify that the table has been uncached.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published