Databricks Data Engineer Professional Question 59
Single answerYou are designing a data pipeline in Databricks to process a large dataset of customer transactions. The dataset contains the following columns: transaction_id, customer_id, transaction_date, store_id, and transaction_amount. The data will be queried frequently by analysts for transactions within specific date ranges and sometimes filtered by store ID. Which strategy should you use to partition the data to optimize query performance and avoid small file issues?
- A
Partition the data by
transaction_dateandstore_id. - B
Partition the data by
customer_idandtransaction_id. - C
Partition the data by
transaction_dateonly. - D
Do not partition the data to avoid creating too many partitions.
Show answer and explanation
Correct answer: A
Explanation
Partitioning the data by transaction_date and store_id balances query performance and partition management. Analysts frequently query by date ranges and occasionally filter by store ID, so including both columns as partitioning keys ensures efficient data retrieval while reducing the likelihood of small file issues. Partitioning by transaction_date alone is suboptimal since it does not account for store-level filtering, and partitioning by high-cardinality columns like customer_id and transaction_id creates too many partitions, leading to poor performance.
- A. Correct.
Partitioning by
transaction_dateandstore_idwill optimize the queries that filter by date ranges and store ID, while balancing the number of partitions to avoid small file issues. - B. Incorrect.
Partitioning by
customer_idandtransaction_idis inefficient because these columns are highly cardinal, leading to excessive partitions and poor query performance. - C. Incorrect.
Partitioning by
transaction_dateonly could improve query performance for date range filters, but it would not optimize queries that also filter bystore_id. - D. Incorrect.
Not partitioning the data is generally not recommended for large datasets, as it can lead to inefficiency in querying and processing.