QuestionQ270

VerifiedTroubleshooting and Tuning Apache Spark DataFrame API Applications.

A developer must write the output from a complex sequence of Spark transformations to a Parquet table named events.live_latest. Consumers of this Parquet table mainly access it through a Spark SQL query with a WHERE clause that filters on both the year and month of the event_ts column. The event_ts column has the TIMESTAMP type.

Question Image

Which modification will allow downstream consumers to efficiently query the table by both the year and month in the event_ts column?

Explanation

Partitioning the Parquet table by both derived columns, event_year and event_month, lays out the data in corresponding directory partitions. Spark can prune irrelevant year/month partitions when predicates filter on both columns, avoiding unnecessary file reads. Bucketing by only event_year and sorting within buckets do not provide that two-column partition-pruning layout.

Learn more

Community Discussion

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