Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Question 50 of 119
Free Preview · 119 of 395 · questions 1–119 of 395 are free. Sign up free to sync your progress across devices.
Select one answer.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
- Correct answer : A — `GROUP BY ROLLUP (region, product_category)`, which produces the detail-level groups plus subtotals for `region` and a grand total, following the hierarchical order of the listed columns. A . Correct. `ROLLUP (region, product_category)` produces the full detail grouping, then a subtotal per `region` (dropping `product_category`), then a single grand total, matching the hierarchical requirement described without needing a `product_category`-only subtotal. B . Incorrect for this requirement. `CUBE` also produces a `product_category`-only subtotal (with region dropped) that was not requested, so it returns a superset of the needed groupings rather than the specific hierarchical set the report calls for. C . Workable but not the right construct here. Manually unioning three separately grouped queries can reproduce the same rows, but it requires three separate scans and aggregations and more code than the purpose-built rollup syntax designed for exactly this hierarchical subtotal pattern. D . Incorrect. Spark SQL's `GROUP BY` clause has no `WITH TOTALS` syntax; that construct does not exist in Spark SQL and the query would fail to parse.