Spark 2 Workbook Answers ❲PRO - PACK❳

val spark = SparkSession.builder() .appName("DeptSalary") .getOrCreate()

# 1️⃣ Load the file as an RDD lines = sc.textFile("hdfs:///data/input.txt")

## 8. Final Checklist Before Submitting

---

## 6. Quick Reference Cheatsheet (Spark 2.4) spark 2 workbook answers

# 3️⃣ Keep only unique words distinct_words = words.distinct()

---

| Tip | How to Apply | |-----|--------------| | **Show Spark’s lazy evaluation** | Mention that transformations build a DAG, actions trigger execution. | | **Explain the physical plan** | Use `df.explain()` in a note to demonstrate understanding of shuffle, broadcast, etc. | | **State assumptions** | “Assume the input file fits in HDFS and each line is a UTF‑8 string.” | | **Edge‑case handling** | Talk about empty files, null values, or malformed CSV rows. | | **Performance hints** | Suggest `repartition` before a heavy shuffle or using `broadcast` for small lookup tables. | | **Testing** | Show a tiny local test (e.g., `sc.parallelize(["a b","b c"]).flatMap(...).collect()`). | | **Clean code** | Use meaningful variable names, consistent indentation, and short comments. |

This website uses cookies. Click here to find out more.

Accept cookies