QuestionQ70

VerifiedUsing Spark SQL

A data engineer has a PySpark DataFrame called sales_data that contains millions of rows. They must calculate the total sales amount by region using Spark SQL to improve readability and maintainability.

Which steps should the data engineer take to accomplish this?

Explanation

createOrReplaceTempView registers a PySpark DataFrame as a temporary view that can be referenced in Spark SQL. The aggregation can then be expressed with SQL, such as SELECT region, SUM(sales_amount) ... GROUP BY region, while retaining Spark's distributed processing.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!