What does createOrReplaceTempView("orders") do?
- Registers a DataFrame so it can be queried with SQL
- Permanently uploads data to Google Drive
- Deletes duplicate rows
- Installs Spark SQL
Answer: 1 Type: single Time: 45 Explanation: A temporary view lets Spark SQL query a DataFrame by name.
Which command runs a SQL query in PySpark?
spark.sql("SELECT * FROM orders")spark.query_csv("SELECT * FROM orders")sql.run("SELECT * FROM orders")orders.sql_only("SELECT *")
Answer: 1
Type: single
Time: 45
Explanation: spark.sql(...) runs SQL and returns a Spark DataFrame.
What does WHERE do in SQL?
- Filters rows
- Starts Spark
- Creates a virtual environment
- Prints the schema
Answer: 1
Type: single
Time: 40
Explanation: WHERE keeps rows that match a condition.
Which SQL clause creates summaries by category or city?
- GROUP BY
- INSTALL BY
- NOTEBOOK BY
- SCHEMA BY
Answer: 1
Type: single
Time: 40
Explanation: GROUP BY groups rows so aggregate functions can summarize each group.
Which expression calculates revenue in the session dataset?
quantity * unit_pricecity * productcategory + cityorder_id / city
Answer: 1 Type: single Time: 45 Explanation: Revenue is quantity multiplied by unit price.
Which SQL query finds total revenue by city?
SELECT city, SUM(revenue) FROM orders GROUP BY citySELECT city FROM orders STOP BY revenueSELECT SUM(city) FROM orders GROUP BY revenueSELECT revenue FROM city GROUP BY orders
Answer: 1 Type: single Time: 60 Explanation: The query groups rows by city and sums revenue in each group.
What does ORDER BY total_revenue DESC do?
- Sorts results from highest total revenue to lowest
- Deletes total revenue
- Groups results by total revenue
- Converts SQL to Python
Answer: 1
Type: single
Time: 45
Explanation: DESC sorts descending.
Which aggregate function counts rows?
- COUNT
- WHERE
- ORDER
- VIEW
Answer: 1
Type: single
Time: 40
Explanation: COUNT(*) counts rows in a group or query result.
Why compare SQL syntax with DataFrame syntax?
- Both can answer analytics questions, and each style is useful in different situations
- SQL is always wrong in PySpark
- DataFrames cannot group rows
- Spark requires both styles in every script
Answer: 1 Type: single Time: 50 Explanation: Spark supports both SQL and DataFrame APIs.
What happens to a temporary view when the Spark session stops?
- It is gone
- It becomes a permanent database
- It turns into a CSV file automatically
- It is committed to GitHub
Answer: 1 Type: single Time: 45 Explanation: Temporary views live only inside the current Spark session.